#29885 [Opn]: recursive functions on get_defined_vars() in PHP5
| From: | curt@php.net | Date: | Tue, 31 Aug 2004 05:07:36 +0000 |
| Subject: | #29885 [Opn]: recursive functions on get_defined_vars() in PHP5 | ||
| References: | 1 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969363599@lists.php.net to get a copy of this message | ||
ID: 29885
Updated by: curt@php.net
Reported By: nospamplease at veganismus dot ch
Status: Open
-Bug Type: *General Issues
+Bug Type: Documentation problem
Operating System: WinXP
PHP Version: 5.0.1
New Comment:
PHP5's get_defined_vars() return's $GLOBALS, which is a recursive
array, which will cause count() to crash.
Moving this as a documentation bug.
Previous Comments:
------------------------------------------------------------------------
[2004-08-29 23:42:53] nospamplease at veganismus dot ch
Description:
------------
it seems that you cant use any recursive function on get_defined_vars()
in PHP5.
<?
$arr = get_defined_vars();
echo 'Number of Defined Vars: ';
echo count($arr,COUNT_RECURSIVE);
?>
in PHP4 this will output some integer like "199" as expected.
in PHP5 this doesnt even output any error report. I just get a
"connection closed by server" message or the like. When changing line 3
to
<?
echo count($arr); // nonrecursive
?>
it outputs something like "7" (which seems to be correct). also if i
use any multi-dimensional array instead of get_defined_vars() the
result will be correct.
Reproduce code:
---------------
<?
$arr = get_defined_vars();
echo 'Number of Defined Vars: ';
echo count($arr,COUNT_RECURSIVE);
?>
Expected result:
----------------
Number of Defined Vars: 199
Actual result:
--------------
The result is nothing (no errormessage by PHP5 or Apache2) so the
acctualy displayed message depends on the browser:
Modzilla: The document contains no data.
Opera: connection closed by server
M$IE: Page Cannot Be Displayed
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=29885&edit=1