[PHP-DEV] PHP 4.0 Bug #4554: An array of objects within an object does not evaluate properly within a string From: jordanh <email protected>
Date: 05/22/00

From: jordanh <email protected>
Operating system: RedHat Linux 5.2 / 2.2.14 SMP
PHP version: 4.0 Release Candidate 2
PHP Bug Type: Scripting Engine problem
Bug description: An array of objects within an object does not evaluate properly within a string

<?
        class child_t {
                var $x;
        }

        class parent_t {
                var $childs;

                function makeChildArray() {
                        for ($i = 0; $i < 10; $i++) {
                                $this->childs[$i] = new child_t;
                                $this->childs[$i]->x = "Value #$i";
                        }
                }
        }

        /* main() */
        $parent = new parent_t;
        $parent->makeChildArray();

        /* Display the values from the "childs" array: */
        for ($i = 0; isset($parent->childs[$i]->x); $i++) {
                /* BUG: See attached note! */
                echo "I am in a string context: $parent->childs[$i]->x!<br>";
                echo "I am <u>not</u> in the string context:"
                    .$parent->childs[$i]->x."<br>";
        }
?>

Compiled with: --with-gettext --with-mysql --with-apache=../apache_1.3.12

The first few lines of the above script is as follows:

I am in a string context: Array[0]->x!
I am not in the string context:Value #0
I am in a string context: Array[1]->x!
I am not in the string context:Value #1

Good Luck!

Jordan.

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
For additional commands, e-mail: php-dev-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>