php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #4554 An array of objects within an object does not evaluate properly within a string
Submitted: 2000-05-22 21:36 UTC Modified: 2000-05-31 10:08 UTC
From: jordanh at remotepoint dot com Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0 Release Candidate 2 OS: RedHat Linux 5.2 / 2.2.14 SMP
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jordanh at remotepoint dot com
New email:
PHP Version: OS:

 

 [2000-05-22 21:36 UTC] jordanh at remotepoint dot com
<?
        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.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-05-31 09:40 UTC] stas at cvs dot php dot net
Not a bug.
If you want to have sull variable evaluation, use "{$obj->val}" syntax
or just use printf.
 [2000-05-31 10:08 UTC] jordanh at remotepoint dot com
Okay, than perhaps it could be explained why full variable evaulation is not
not the default behavior in the string context?  It seems a wee bit inconsistant.

But then again, it is your software.

Could we change this bug from a failure type to a change request?


Jordan.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 06:01:38 2025 UTC