ID: 28505 Updated by: [EMAIL PROTECTED] Reported By: lars_stegelitz at col dot wunderman dot com -Status: Feedback +Status: No Feedback Bug Type: Class/Object related Operating System: Windows 2000 PHP Version: 4.3.4 New Comment:
No feedback was provided for this bug for over a week, so it is being suspended automatically. If you are able to provide the information that was originally requested, please do so and change the status of the bug back to "Open". Previous Comments: ------------------------------------------------------------------------ [2004-12-13 00:59:16] [EMAIL PROTECTED] Please try using this CVS snapshot: http://snaps.php.net/php4-STABLE-latest.tar.gz For Windows: http://snaps.php.net/win32/php4-win32-STABLE-latest.zip ------------------------------------------------------------------------ [2004-05-24 14:02:01] lars_stegelitz at col dot wunderman dot com Description: ------------ Assume a class with overload-support. Now, if you use an instance of that class to __set/__get a property (of type string) an try to concatenate it with the return value of another function (which returns a string like session_id()) some strange things gonna happen. The actual return value (of the string-returning function, session_id() in this example) will be changed to '1'! (see code and the actual/expected results... notice, that the session_id may differ, but it's never expected to give '1' as a session_id) However, if a constant string (or if the return value is temporarily stored into another variable) is concatenated to the property, everthing works fine (see comments in the code). PHP configuration is: - Win 2000 SP4 - minixampp containing - Apache/2.0.48 (Win32) - PHP/4.3.4 Reproduce code: --------------- <?php class A { function A() { echo "A constructed<br>\n"; } function __get($key, &$value) { $value = $_SESSION[$key]; echo "__get was called with '$key' <br>\n"; return true; } function __set($key, $value) { $_SESSION[$key] = $value; echo "__set was called with '$key' = '$value' <br>\n"; return true; } } overload('A'); session_name("my_session"); session_start(); # make sure, a session is started $a =& new A(); $a->my_var = "test"; $res = $a->my_var.session_id(); # <- doesn't work properly! # the following one will work as expected # $res = $a->my_var."_constant_string"; # (produces output: "test_constant_string") # this one is ok, too: # $res = $a->my_var."".session_id(); echo "concat test :".$res."<br>\n"; echo "session id : ".session_id()."<br>\n"; ?> Expected result: ---------------- A constructed __set was called with 'my_var' = 'test' __get was called with 'my_var' concat-test : test31b4ed95c6d107d9e40368c160843d8e session id : 31b4ed95c6d107d9e40368c160843d8e Actual result: -------------- A constructed __set was called with 'my_var' = 'test' __get was called with 'my_var' concat-test : test1 session id : 31b4ed95c6d107d9e40368c160843d8e ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=28505&edit=1