Quote in Constructors

Source: Internet
Author: User
References in constructors
Just started to learn PHP in the PHP manual see the reference to the constructor in this section below I wrote it according to the manual, but the test results are different from what the manual says.

 
  Class foo{
function Foo ($name) {
Global $globalref;
$globalref [] = & $this;

$this->setname ($name);

$this->echoname ();

}

function Echoname ()
{
Echo '
', $this->name;
}

function SetName ($name)
{
$this->name = $name;
}
}
?>


$bar 1 = new Foo (' Set the name is PHP ');

$bar 1->echoname ();
$globalref [0]->echoname ();

Print_r ($GLOBALREF);

$bar 1->setname (' Set the name is Java ');
$bar 1->echoname ();
$globalref [0]->echoname ();
?>

------Solution--------------------
I don't know what you're describing as a "handbook."
At least from the code is based on the PHP4, as to whether in the php4 of the performance, no environment, it is unclear

------Solution--------------------
Yes, PHP5 's kernel is the same as PHP4, otherwise it's not php5 but php4.x.
As with all software systems, a change in the big version indicates a significant change.
Although there is not much difference from the point of view of PHP code, there is a change in the way of implementation. Can be thought of as essentially two languages
Therefore, the interpretation based on PHP4 cannot be used for PHP5.

Don't you see that there is an applicable version number on each function explanation page in the manual?
  • 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.