Here's the problem again, Daniel.
Error_reporting (E_all | E_STRICT);
Class mycls{
Private $p = 1;
/** the overloaded data is stored here */
Private $data = Array ();
function func ()
{
echo "None static";
}
/* Public Function __set ($name, $value)
{
echo "Setting ' $name ' to ' $value '
\ n ";
$this $name = $value;
} */
Public Function __get ($name)
{
echo "Getting ' $name '
\ n ";
return $this $name;
}
}
$my =new mycls;
$my->a=10; //
Echo $my->a;
?>
------Solution--------------------
No problem.
------Solution--------------------
You have $my->a=10;.
Of course, it won't call __get.
------Solution--------------------
Written like this, it's all there.
PHP Code
Error_reporting (E_all | E_STRICT); class mycls{Private $p = 1; /** the overloaded data is stored in this */private $data = Array (); function func () {echo "None static"; Public Function __set ($name, $value) {echo "Setting ' $name ' to ' $value '
\ n "; $this->data[$name] = $value; } Public Function __get ($name) {echo "Getting ' $name '
\ n "; return $this->data[$name]; }} $my =new mycls; $my->a=10; Echo $my->a;
------Solution--------------------
Erer
------Solution--------------------
$my =new mycls;
echo$my->a;//, the direct output will be called.
Without the Echo statement, the direct assignment is called __set
But you're logged out of the code.
------Solution--------------------
discuss
Reference:
Reference:
Written like this, it's all there.
PHP Code
Error_reporting (E_all | E_STRICT);
Class mycls{
Private $p = 1;
/** the overloaded data is stored here */
Private $data = Array ();
function func ()
{
echo "None sta ...