You are here: Re: Referencing returned objects directly « PHP Programming Language « IT news, forums, messages
Re: Referencing returned objects directly

Posted by Jeff on 03/20/07 17:34

On Mar 19, 12:45 pm, "ZeldorBlat" <zeldorb...@gmail.com> wrote:
> 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;
> ?>

I think it only works in PHP 5+ not in PHP 4. WIth PHP 4 you have to
set it to a variable then use that variable to call the function as
you have in your OP.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация