I tried all the tricks available in the net, but dont know why, i am not able to access the variable.. heres the snippet of class containing private variable:
class PANASONIC_PRICESHEET {
public $models = array();
public $options = array();
public $accessories = array();
private $identifier = '';
private $name = '';
private $currency1 = '€';
private $currency2 = '£';
/**
*
*/
public function __construct($name1 = 'unnamed', $identifier1 = '') {
$this->name = $name1;
$this->identifier = $identifier1;
}
public function getIdentifier() {
return $this->identifier;
}
/**
*
*/
public function getName($withIdentifier = false) {
if ($withIdentifier) {
return $this->name . " - " . $this->identifier;
} else {
return $this->name;
}
}
}
And here is how i am accessing it:
$thisName = $pricesheet->getName();
$thisIdentifier = $pricesheet->getIdentifier();
And I am getting this error:
Fatal error: Cannot access private property PANASONIC_PRICESHEET::$name in
C:\AppServ\www\dashboard\sites\all\modules\_custom\pricing_system\pricing_system.inc
on line 316
How to fix this? I cannot make the field PUBLIC, its not a option at all. Any suggestions please.
EDIT – 1
Issue has been solved:
I was suppose to call $_pricesheet->getName();
thanks a lot for suggestions.
This is currently working for me. Take a look here. You must be probably trying to access
$pricesheet->name;