|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-07-29 11:29 UTC] bastard dot internets at gmail dot com
[2010-07-30 06:51 UTC] bastard dot internets at gmail dot com
[2010-08-01 15:27 UTC] felipe@php.net
[2010-08-01 15:27 UTC] felipe@php.net
-Status: Open
+Status: Closed
-Package: Class/Object related
+Package: Scripting Engine problem
-Operating System: WIN
+Operating System: Irrelevant
-Assigned To:
+Assigned To: felipe
[2010-08-01 15:27 UTC] felipe@php.net
[2010-08-02 20:29 UTC] bastard dot internets at gmail dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 06:00:01 2025 UTC |
Description: ------------ Within only __set(), you can set a value of a new property with an empty name ($p = null; $this->$p = 1;). The property won't really be created though - the effects will be invisible to the user. No errors, warnings, or notices are generated. This lack of an error message might cause difficult to pinpoint bugs since all assignments of previously undeclared properties within object scope regardless of originating method are routed through __set(); Elsewhere in the object, attempting this will cause a fatal 'Cannot access empty property' error as expected. Test script: --------------- <?php class A{ function __set($prop, $val) { echo "SET $prop = $val\n"; $this->$prop = $val; // should've caused error } } $a = new A(); $prop = null; $a->$prop = 2; print_r($a); // empty object ?> Expected result: ---------------- fatal 'Cannot set empty property' or 'invalid property name' error. Actual result: -------------- Nothing.