You are here: Re: ERROR: signing the return value of new by reference « PHP Programming Language « IT news, forums, messages
Re: ERROR: signing the return value of new by reference

Posted by Andy Hassall on 12/20/06 21:33

On 19 Dec 2006 17:42:29 -0800, "seaside" <seaside.ki@mac.com> wrote:

>Andy Hassall schrieb:
>
>> On 19 Dec 2006 14:27:26 -0800, "johnny" <rampeters@gmail.com> wrote:
>>
>> >I have the following PHP code. I am using PHP 5.1.6.
>> >
>> >$req =& new HTTP_Request($this->accessUrl);
>> >
>> >I am getting the following errors:
>> >Strict Standards: Assigning the return value of new by reference is
>> >deprecated in c:\mysite\lib\simpleTest.php on line 80
>>
>> Objects are always passed by reference in PHP 5 hence the warning of
>> deprecation of the effective double-reference.
>>
>> Obviously if you have to support PHP 4 then you must keep the & - in which
>> case you need to disable E_STRICT from error_reporting.
>
>Just for the sake of clearness: Any assignment of an object to a
>variable creates a copy of the object? A shallow object, I suppose?

Assignment with "=" instead of "=&" on PHP4 creates a shallow copy of the
object.

Assignment with "=" on PHP5 does not create a copy; you use the clone keyword
for that, which by default makes a shallow copy, but you can override the
__clone() method in the object to do any deep copying or other operations if
required.

--
Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool

 

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

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