Why isn't the filename being included in the path when calling the getLivePath(); and getDevPath(); methods?
<?php
class supplierImport {
var $_supplierFilename = '';
var $_fileName = '';
var $_livePath = '/var/www/vhosts/myshop.co.uk/httpdocs/_import/';
var $_devPath = '/var/www/web-ecommerce/www/_import/';
function supplierImport($supplier){
switch($supplier){
case 'birlea';
$birlea = new birlea();
break;
case 'julianbowen';
$julianbowen = new julianbowen();
default;
echo 'Supplier not available';
break;
}
}
function getLivePath(){
return $this->_livePath.'/'.$this->_fileName;
}
function getDevPath(){
return $this->_devPath.'/'.$this->_fileName;
}
}
class birlea extends supplierImport {
function birlea(){
$this->_fileName = 'birlea_stock.csv';
}
}
class julianbowen extends supplierImport {
function julianbowen(){
$this->_fileName = 'julianbowen_stock.csv';
}
}
$supplierImport = new supplierImport('birlea');
echo $supplierImport->getLivePath();
echo $supplierImport->getDevPath();
This is the output I get:
/var/www/vhosts/myshop.co.uk/httpdocs/_import///var/www/web-ecommerce/www/_import//
Example code:
http://sandbox.onlinephpfunctions.com/code/435a4b25db44d2c8bb33ff6aa2d96c6db21ef177
$supplierImport = new supplierImport('birlea')- this still gets you an instance of yoursupplierImportclass. The mere fact that inside the constructor you create an instance ofbirleawith$birlea = new birlea()doesn’t change anything about that. Yes,$birleanow contains abirleainstance for which the constructor of that class has been called. But this does not influence what you got stored in$supplierImportone single bit.