Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Assigning the return value of new by reference is deprecated

Tags:

php

php-5.2

I've just got an error.

When I try to assign an object like this:

$obj_md = new MDB2(); 

The error I get is "Assigning the return value of new by reference is deprecated". Actually I've been looking for a solution but the only one I've seen is just turn down the politicy of php.ini (error_reporting). I've tried it too, but it didn't work.

It's so confusing..I hope you could help me. Thanks in advance.

like image 536
José M. Gilgado Avatar asked Jul 06 '09 11:07

José M. Gilgado


1 Answers

In PHP5 this idiom is deprecated

$obj_md =& new MDB2(); 

You sure you've not missed an ampersand in your sample code? That would generate the warning you state, but it is not required and can be removed.

To see why this idiom was used in PHP4, see this manual page (note that PHP4 is long dead and this link is to an archived version of the relevant page)

like image 88
Paul Dixon Avatar answered Sep 21 '22 12:09

Paul Dixon