ID:               35905
 Updated by:       [EMAIL PROTECTED]
 Reported By:      benadin at ukr dot net
-Status:           Open
+Status:           Assigned
 Bug Type:         Scripting Engine problem
 Operating System: FreeBSD 5.4
 PHP Version:      5.1.1
-Assigned To:      
+Assigned To:      dmitry
 New Comment:

I get the same (i.e. "actual") result with: 5.0.4, 5.0.3 and 4.4.x, so
this problem wasn't introduced in 5.1.1.
Also I should note that changing StructAddNodePointer definition to
"function &StructAddNodePointer()" fixes it.
Dmitry, please take a look at it.


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

[2006-01-05 14:31:10] benadin at ukr dot net

Description:
------------
In the code below method StructAddNodePointer gets a part (branch) of
the array (in the example $bar->dxml_struct_arr) and fills it. It works
in PHP 5.0.5 but doesn't work in PHP 5.1.1. It seems in PHP 5.1.1
passing &$dxml_struct_arr by reference doesn't work. Or may be it
doesn't work here: $pointer_tree_doc_value =
&$bar->StructAddNodePointer('doc', $bar->dxml_struct_arr);

Reproduce code:
---------------
class foo {
        function StructAddNode($tag, &$dxml_struct_arr, $attribs = array()) {
                $dxml_struct_arr[] = array(
                        'tag' => $tag,
                        'value' => null #array()
                );
                $index= (sizeof($dxml_struct_arr)-1);
                return $index;
        }
        function StructAddNodePointer($tag, &$dxml_struct_arr, $attribs =
array()) {
                $index = $this->StructAddNode($tag, $dxml_struct_arr, $attribs);
                return $dxml_struct_arr[$index]['value'];
        }
}
$bar = new foo();
$bar->dxml_struct_arr = array();
$pointer_tree_doc_value = &$bar->StructAddNodePointer('doc',
$bar->dxml_struct_arr);
$pointer_tree_head_value = &$bar->StructAddNodePointer('HEAD',
$pointer_tree_doc_value);
print_r($bar->dxml_struct_arr);

Expected result:
----------------
Array
(
    [0] => Array
        (
            [tag] => doc
            [value] => Array
                (
                    [0] => Array
                        (
                            [tag] => HEAD
                            [value] => 
                        )

                )

        )

)


Actual result:
--------------
Array
(
    [0] => Array
        (
            [tag] => doc
            [value] => 
        )

)



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


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

Reply via email to