|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2017-04-02 11:29 UTC] nikic@php.net
-Summary: Magic function __get have different behavior in php
7.1.x
+Summary: Magic function __get has different behavior in php
7.1.x
-Type: Feature/Change Request
+Type: Bug
[2017-04-02 11:31 UTC] nikic@php.net
[2017-04-02 11:31 UTC] nikic@php.net
-Status: Open
+Status: Closed
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 13:00:01 2025 UTC |
Description: ------------ Does the recursive call to the magic method be allowed? Actual result in php 5.x and 7.0.x: __get test PHP Notice: Undefined property: Test::$test in /data1/data/playcrab/tmp/test4.php on line 10 __get test2 PHP Notice: Undefined property: Test::$test in /data1/data/playcrab/tmp/test4.php on line 12 Actual result in php 7.1.x: __get test PHP Notice: Undefined property: Test::$test in /data1/data/playcrab/tmp/test4.php on line 10 __get test2 __get test Test script: --------------- <?php class Test { public function __get($var) { static $first = true; echo '__get '.$var.PHP_EOL; if ($first) { $first = false; $this->$var; $this->{$var.'2'}; $this->$var; } } } $test = new Test; $test->test; Expected result: ---------------- __get test __get test __get test2 __get test Actual result: -------------- __get test PHP Notice: Undefined property: Test::$test in /data1/data/playcrab/tmp/test4.php on line 10 __get test2 __get test