ID: 31010
Updated by: [EMAIL PROTECTED]
-Summary: echo a variable that was unset before breaks output
Reported By: lars_stegelitz at col dot wunderman dot com
-Status: Open
+Status: Verified
-Bug Type: Output Control
+Bug Type: Class/Object related
-Operating System: Windows
+Operating System: *
-PHP Version: 4.3.9
+PHP Version: 4CVS (2004-12-08)
New Comment:
Most likely the lack of output is because there is a crash in PHP,
backtrace as follows:
[Switching to Thread 1087948032 (LWP 19451)]
0x082a359c in execute (op_array=0x8624c4c) at
/usr/src/web/php/php4/Zend/zend_execute.c:1370
1370
PZVAL_UNLOCK(*EX(Ts)[EX(opline)->result.u.var].var.ptr_ptr);
(gdb) bt
#0 0x082a359c in execute (op_array=0x8624c4c)
at /usr/src/web/php/php4/Zend/zend_execute.c:1370
#1 0x08290eed in zend_execute_scripts (type=8, retval=0x0,
file_count=3)
at /usr/src/web/php/php4/Zend/zend.c:900
#2 0x082589f9 in php_execute_script (primary_file=0xbfffe490)
at /usr/src/web/php/php4/main/main.c:1736
#3 0x082b68e9 in main (argc=2, argv=0xbfffe524)
at /usr/src/web/php/php4/sapi/cli/php_cli.c:822
#4 0x42015704 in __libc_start_main () from /lib/tls/libc.so.6
Previous Comments:
------------------------------------------------------------------------
[2004-12-07 16:38:58] lars_stegelitz at col dot wunderman dot com
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...
------------------------------------------------------------------------
[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