Basic question: Object reference problem?

Source: Internet
Author: User
 
 My_val=5;global $global _obj, $global _obj->my_val=10;echo $p->my_val;  Output 5var_dump ($p = = = $global _obj);  Back to False?>


Ask why the result is 5 instead of 10;
My understanding is: in PHP5, unless you explicitly clone an object with the Clone keyword, the object will never be copied unconsciously.
Does that make sense?


Reply to discussion (solution)

Line 8th $global _obj=& $this; When
The 18th Guild has
Creating default object from empty value (creation of defaults from null values)
Warning, you blocked the error message, so you can't figure out why.

When line 8th is corrected for $global _obj = $this; When
You can output 10.

Recommended to see the http://php.net/manual/zh/language.oop5.references.php

  • 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.