A community in which webmasters can ask for help with topics such as PHP coding , MySQL , IT jobs, web design, IT security.
Current location:homephp forumphp talk in 2008 yearPHP new operator returning reference - page 1
User InfoPosts
PHP new operator returning reference#1
I'm working with some old PHP code that has a lot of the following:

$someVar =& new SomeClass();

Did the new operator ever return a value, um, not by reference? (That feels strange to type. I feel like I'm losing my mind.)

posted date: 2008-12-08 13:15:00

Re: PHP new operator returning reference#2
I had made out the solution of this problem. click to view my topic...

hope that hepls.

posted date: 2008-12-08 13:15:01

Re: PHP new operator returning reference#3
Thats PHP4 code. From the documentation: (now removed)"new" does not return a reference by default, instead it returns a copy. [1]: http://no.php.net/manual/en/language.oop.newref.php

posted date: 2008-12-08 13:19:00

Re: PHP new operator returning reference#4
It was one of those sort of optimization techniques taught in a lot of older books on OOP in PHP 4.Basically, the initial object created in memory is one the application can't access unless you return the instance by reference. Otherwise you get a copy of the object - the only catch is that the original exists without a symbol. Kinda dumb.But ya, object creating and passing and references in PHP 4 is a monumental mess.

posted date: 2008-12-08 13:25:00

Re: PHP new operator returning reference#5
I got a -1 for this correct answer?

posted date: 2008-12-08 14:48:00

Re: PHP new operator returning reference#6
Broken link....

posted date: 2013-07-05 10:01:00

Re: PHP new operator returning reference#7
@Pacerier it wasn't broken when I added it...

posted date: 2013-09-25 13:31:00

select page: « 1 »
Copyright ©2008-2017 www.momige.com, all rights reserved.