Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP 5 and "& new"

Tags:

php

this statement:

$node_obj =& new someClass($somearg, $moreargs);

generate an error in the latest version of PHP right?

I have tried it on my machine (PHP >= 5.0.0 & <=5.2.17) and I get this error:

Deprecated: Assigning the return value of new by reference is deprecated in test.php on line 1108

like image 987
xRobot Avatar asked Nov 02 '10 22:11

xRobot


1 Answers

Remove the &.

Objects are passed as reference by default in PHP 5, which is why using the & is deprecated in this context.

like image 160
Pekka Avatar answered Nov 18 '22 19:11

Pekka