|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-11-14 06:36 UTC] lbarnaud@php.net
[2008-11-14 21:47 UTC] ms419 at freezone dot co dot uk
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 26 10:00:01 2025 UTC |
Description: ------------ I have a class (in the reproduce code "Test") which is basically a container for some attributes. Some of the attributes are the results of expressions which I only want to evaluate when the attribute is accessed for the first time. The __get() function seems perfect for this. One attribute is "repository" - its value should be the result of an expression, concatenated with a slash character and another attribute ("name"), if "name" is not null. When "name" is not null, the first time "repository" is accessed, __get() returns the result of the expression, without anything concatenated. The second time "repository" is accessed, __get() returns just a slash character and "name", without the result of the expression. Reproduce code: --------------- http://cgi.sfu.ca/~jdbates/tmp/php/200811130/test.phps Expected result: ---------------- ket% php test.php string(9) "some expr/name" string(4) "some expr/name" ket% Actual result: -------------- ket% php test.php string(9) "some expr" string(4) "/name" ket%