php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #9587 obj->method()->method2() doesn't work!!
Submitted: 2001-03-06 15:31 UTC Modified: 2001-12-01 12:09 UTC
From: docwhat at gerf dot org Assigned:
Status: Closed Package: Class/Object related
PHP Version: 4.0.4pl1 OS: Linux/Debian(Woody)
Private report: No CVE-ID: None
 [2001-03-06 15:31 UTC] docwhat at gerf dot org
You cannot do the following:

obj->method()->method2();

Mini example:
class Foo{
 var $obj;
  
 setObj( &$obj ) {
   $this->obj =& $obj;
 }

 &getObj() {
   return $this->obj;
}

 hello() {
   print "hi\n";
 }
}

$a = new Foo;
$b = new Foo;
$b->setObj( $a );

$a->getObj()->hello();
// Doesn't work

In fact, this doesn't work either:
function foob() {
  global $a;
  return $a;
}

foo()->hello();

In addition, anything that hands objects back doesn't work
right.  You can't chain certain things, like new commands.

All in all, the objects are rather inflexable.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-03-08 12:43 UTC] stas@php.net
Yes, this is a known problem. 
 [2001-12-01 12:09 UTC] sebastian@php.net
Not a bug, closing.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 22:01:28 2024 UTC