Reply to Re: Strange notation to create object

Your name:

Reply:


Posted by Matthew Weier O'Phinney on 11/09/35 11:19

* Michael Stepanov <michaelstepanov@francoudi.com>:
> Usually, I develop on Perl. But my current task pushes me to start use
> PHP. Generally, it's great but sometimes I'm a little bit confused.
> For example, recently I've found a strange notation of creation of PHP
> objects:
>
> $obj = & new SomeObject();
>
> Can anyone explain me meaning of *&*?

& is used to create references -- kind of like \ in perl.

The above notation is unnecessary when developing in PHP5, as objects in
PHP5 are passed by reference by default. However, in PHP4, this was
often necessary if you needed to, for instance, store an object in an
array or another object (otherwise you got a copy of the object, which
means state would then differ between the original and the copy).

--
Matthew Weier O'Phinney | WEBSITES:
Webmaster and IT Specialist | http://www.garden.org
National Gardening Association | http://www.kidsgardening.com
802-863-5251 x156 | http://nationalgardenmonth.org
mailto:matthew@garden.org | http://vermontbotanical.org

[Back to original 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

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