Here comes the question again, Daniel.

Source: Internet
Author: User
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 ...
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.