#31010 [Opn]: echo a variable that was unset before breaks output

From: Date: Tue, 07 Dec 2004 15:39:05 +0000
Subject: #31010 [Opn]: echo a variable that was unset before breaks output
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-69888@lists.php.net to get a copy of this message
ID: 31010 User updated by: lars_stegelitz at col dot wunderman dot com Reported By: lars_stegelitz at col dot wunderman dot com Status: Open Bug Type: Output Control Operating System: Windows PHP Version: 4.3.9 New Comment: addition: The error-suppression operator (@) in the __set/__get methods should be omitted to see a warning in standard cases. However, it makes no difference in case of the mentioned error... Previous Comments: ------------------------------------------------------------------------ [2004-12-07 16:31:21] lars_stegelitz at col dot wunderman dot com Description: ------------ When trying to echo an variable that was previously unset, no output at all is shown. I wrote a small test case (see below) Reproduce code: --------------- class Test { var $values; function Test() { $this->values = array(); } function __get($key, &$value) { $value = @$this->values[$key]; return true; } function __set($key, $value) { $this->values[$key] = @$value; return true; } } overload('Test'); $test = new Test(); $test->xyz = "test"; echo "<br/>1. {$test->xyz}"; unset($test->values['xyz']); echo "<br/>2. {$test->xyz}"; Expected result: ---------------- 1. test Notice: Undefined variable: xyz in <sourcecode> on line <x> 2. Actual result: -------------- Nothing. No output at all. No warning or error in log files or on screen. Not even the echo *before* unsetting the variable shows up. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=31010&edit=1

« previous php.bugs (#69888) next »