php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60376 Discrepency with var_dump
Submitted: 2011-11-24 20:57 UTC Modified: 2011-11-24 22:15 UTC
Votes:1
Avg. Score:2.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: yann-gael at gueheneuc dot net Assigned:
Status: Wont fix Package: Testing related
PHP Version: Irrelevant OS: Windows 7 and AmigaOS v3.1
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: yann-gael at gueheneuc dot net
New email:
PHP Version: OS:

 

 [2011-11-24 20:57 UTC] yann-gael at gueheneuc dot net
Description:
------------
Hello,

I compiled PHP 4.2.3 for m68k-amigaos and the test case tests/lang/029.php fails. I tracked what could be a related bug: https://bugs.php.net/bug.php?id=7515. Could someone tell me more about what has been changed into the Zend engine to fix this earlier bug so that I can track this change and the bug? Or could someone explain me the meaning of the "&" in that particular case.

Code to execute:
    class obj {
            function method() {
            }
    }
    $o->root=new obj();
    var_dump($o);

    $o->root->method();
    var_dump($o);

and its output with PHP 4.2.3 compiled for m68k-amigaos:
    object(stdClass)(1) {
      ["root"]=>
      object(obj)(0) {
      }
    }
    object(stdClass)(1) {
      ["root"]=>
      &object(obj)(0) {
      }
    }

(note the ampersand in the second dump), while, with PHP 5.2.14 on Windows 7, the output is:
    object(stdClass)#2 (1) {
      ["root"]=>
      object(obj)#1 (0) {
      }
    }
    object(stdClass)#2 (1) {
      ["root"]=>
      object(obj)#1 (0) {
      }
    }

Does it make sense that in the second statement "$o->root->method();", the method is viewed as a reference to an object?

Please forgive me if my question is silly, I am a newbie in OO PHP.

Thanks,
Tygre

Test script:
---------------
    class obj {
            function method() {
            }
    }
    $o->root=new obj();
    var_dump($o);

    $o->root->method();
    var_dump($o);


Expected result:
----------------
    object(stdClass)#2 (1) {
      ["root"]=>
      object(obj)#1 (0) {
      }
    }
    object(stdClass)#2 (1) {
      ["root"]=>
      object(obj)#1 (0) {
      }
    }


Actual result:
--------------
    object(stdClass)(1) {
      ["root"]=>
      object(obj)(0) {
      }
    }
    object(stdClass)(1) {
      ["root"]=>
      &object(obj)(0) {
      }
    }


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-11-24 22:15 UTC] cataphract@php.net
That output is indeed strange; however:

1) PHP 4.2.3 was released more than 9 years ago and is no longer supported.
2) This is not a support forum.

In any case, I'll advise to look at http://php.net/manual/en/faq.migration5.php
One of the most significant changes related to objects was that a level of indirection was added.
 [2011-11-24 22:15 UTC] cataphract@php.net
-Status: Open +Status: Wont fix
 [2011-11-24 22:57 UTC] yann-gael at gueheneuc dot net
Thank you Cataphract, I will have a look at the URL you gave. Right now, I am keen on PHP 4.2.3 only because it has already been compiled for m68k-amigaos: I am trying to reproduce the whole compilation tool chain before attacking the next, much more interesting challenge indeed: compiling PHP 5 :-)
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Thu Jul 18 17:01:26 2019 UTC