For Programmers: Free Programming Magazines  


Home > Archive > PHP Documentation > February 2007 > #40204 [Ana->Csd]: "Example 21-3. References with complex arrays" is wro









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author #40204 [Ana->Csd]: "Example 21-3. References with complex arrays" is wro
colder@php.net

2007-02-25, 7:00 pm

ID: 40204
Updated by: colder@php.net
Reported By: frode at coretrek dot com
-Status: Analyzed
+Status: Closed
Bug Type: Documentation problem
Operating System: Irrelevant
PHP Version: 5.2
-Assigned To:
+Assigned To: colder
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.

Warning removed.


Previous Comments:
------------------------------------------------------------------------

[2007-01-23 09:18:15] bjori@php.net

This is complicated issue and _not_ recommended.

The engine still has problem working with complex arrays
with references to it self and leaks tons of memory while
doing so.

The example itself works as of 5.1 but still leaks and
_can_ result in unexpected behavior.

------------------------------------------------------------------------

[2007-01-23 08:38:14] frode at coretrek dot com

Description:
------------
Exmaple 21-3 "References with complex arrays" as available on
http://www.php.net/manual/en/langua...nces.whatdo.php is not
correct, at least not for PHP version 5.2.0.

The example claims to "not work as expected". But it does work as
expected (and contrary to the documented results). Also, even if the
example did "not work as expected", there is no explanation for why it
is not supposed to work, other than stating that complex arrays
"sometimes" (?!?) are copied.

Reproduce code:
---------------
<?php
// taken directly from Example 21-3
$top = array(
'A' => array(),
'B' => array(
'B_b' => array(),
),
);

$top['A']['parent'] = &$top;
$top['B']['parent'] = &$top;
$top['B']['B_b']['data'] = 'test';
print_r($top['A']['parent']['B']['B_b'])
; // array()
?>

Expected result:
----------------
According to the documentation:

array()



Actual result:
--------------
Array
(
[data] => test
)




------------------------------------------------------------------------


--
Edit this bug report at http://bugs.php.net/?id=40204&edit=1
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com