php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #29885 recursive functions on get_defined_vars() in PHP5
Submitted: 2004-08-29 23:42 UTC Modified: 2004-09-06 22:16 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: nospamplease at veganismus dot ch Assigned:
Status: Closed Package: Documentation problem
PHP Version: 5.0.1 OS: WinXP
Private report: No CVE-ID: None
 [2004-08-29 23:42 UTC] 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-08-31 07:07 UTC] 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-09-06 22:16 UTC] curt@php.net
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.
 [2020-02-07 06:11 UTC] phpdocbot@php.net
Automatic comment on behalf of curt
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=f25afe6fbcd69f52931a7a77bd5c0167a713dcbc
Log: fix #29885, count() doesn't handle infinite recursion.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Sep 20 23:01:26 2024 UTC