Nofel Nofel - 2 months ago 5x
PHP Question

setters won't get the new getters values

I am trying following script but it doesn't seem to pick up new value processed bt

i am trying to read through this article to get hold of OOP working my way up to magento. Is there is something missing?

class MyClass{
public $name = "Mike";

private function __setProperty($newval){
$this->name = $newval;

public function __getProperty(){
return $this->name;
$obj = new MyClass;

echo $obj->name;
echo $obj->getProperty();


Mistake here $obj->getProperty("Angela"); you need to use setProperty

echo $obj->name;
echo $obj->getProperty();

and your function are public not private

And i think you want __set, here an exemple of PHP docs:

public function __set($name, $value)
    $this->data[$name] = $value;