|
Posted by ZeldorBlat on 03/19/07 19:45
On Mar 19, 10:59 am, "lister" <listerofsme...@hotmail.com> wrote:
> Hi all,
>
> Is it possible to directly reference an object that is returned by a
> function in PHP?
>
> ie this:
> echo ReturnAnObject()->SomeMember;
>
> instead of this:
> var $Object = ReturnAnObject();
> echo $Object->SomeMember;
>
> 'cus I can't work out the syntax if it is. :-(
>
> Cheers,
> Lister
This code works fine for me:
<?php
class foo {
public $bar = 'bar';
}
function baz() {
return new foo();
}
echo baz()->bar;
?>
Navigation:
[Reply to this message]
|