Object replication for PHP5

Source: Internet
Author: User

Today with YII development program, a bug changed the night, finally found that the problem in the object replication mechanism, PHP5 before the object copy only need $object_a = $object _b can, but PHP5 this is a shallow copy, and pointers, not real data replication, such as change $object the value of the _b, the $object_a will change as well, so $object_a = Clone $object _b, so $object_a will not follow the change.

However, there is a problem, clone is also PHP5 only, so if the design object replication, then PHP5 as a demarcation version, compatibility issues need to be noted.

Note: Yii2.0 supports PHP5 and above by default, so this issue is not covered in Yii2, and does not include the Yii 1.X version.

Object replication for PHP5

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.