#29885 [Opn->Csd]: recursive functions on get_defined_vars() in PHP5
| From: | curt@php.net | Date: | Mon, 06 Sep 2004 20:16:24 +0000 |
| Subject: | #29885 [Opn->Csd]: recursive functions on get_defined_vars() in PHP5 | ||
| References: | 1 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969363840@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
+Status: Closed
Bug Type: Documentation problem
Operating System: WinXP
PHP Version: 5.0.1
New Comment:
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation
better.
Previous Comments:
------------------------------------------------------------------------
[2004-08-31 07:07:34] curt@php.net
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.
------------------------------------------------------------------------
[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