Depreciation Error?

Hello, I had not accessed one of my sites in quite awhile. When I visited it recently I find that it just loads a bunch of errors;

Deprecated: Assigning the return value of new by reference is deprecated in…

Can anyone let me know what this means?

Thanks for the help,


If you’re getting deprecated errors that you didn’t see before (which IMHO you shouldn’t be seeing on any pages of a live site, only in your error logs), it means your version of PHP has been updated. Deprecated means that a “style” of coding that was OK in an earlier version will at some point cease to work. The deprecated errors give you a chance to fix things before another version comes out that will no longer support that style of coding.

I’m not too much into OOP (years and years of procedural have hindered me a bit I’m afraid), but “new” suggests an object. “reference” means the actual object and not a “copy” of it.

I get lots of these errors in my WordPress blog. Why? Because WordPress wants to maintain support for PHP version 4. And as the code still “works” in PHP version 5, I guess they’re in no rush to fix things quite yet.

If the errors are coming from 3rd party files, or if it’s your code and it might be used by others using PHP 4 you may not have much choice but to live with them for now.

But if it’s your code and you’re certain you won’t be using PHP version 4 again, IMHO you should make an effort to fix the errors.

I would be very interested in seeing an example line of code that’s throwing the error and how others would change things.

it is because of difference between OOP support in php 4 and 5
PHP 5.3.0 and above generates this in E_STRICT settings

you dont need to pass it by reference
somewhere may be you are doing like this:
$node_obj = new someClass(& $somearg, & $moreargs);

remove those &,i think it will solve the problem

I agree that removing the "&"s - the “reference” - will get rid of the errors. But I don’t know enough about OOP to know whether or not the “reference” should be removed. Might it be possible that the actual values - as opposed to “copies” - should be used, and if so is there a way to determine that?

The quoted error is not because of using references like those in the quote above, it is due to using:

$blah = & new MyClass();

In PHP 4, instances of classes were usually assigned in this manner. PHP 5 assigns new instances by reference without having to use the & operator.

If the & operator is being used in front of function/method arguments, a different error will be issued making note that call-time pass by reference is deprecated; see here.

PHP 5.3+ has many functions which are depreciated. if you still do coding with depreciated function in some server you can face issue

@Salathe, Thanks, If new instances are assigned by reference without it then it shouldn’t do any harm at all to remove the "&"s, great to know.

You didn’t mention this so I may be going off topic. But did you get any “can not be called statically” errors too? If so, can these be fixed by changing something like

$myVal = Object::method();


$myObj = new Object;
$myVal = $myObj->method();

Thanks all! To clarify a bit, this is on my site … as you can see the page is not even loaded. It is a WordPress and vBulletin, integrated together.

I believe my host must have upgraded the PHP which screwed everything up! Is there an easy fix or do I need redo my whole site? The problem is it’s not just a matter of dropping and dragging new files, I have many custom templates and features that I fear will go haywire if I upgrade…

Any advice is appreciated.



Not good. You may not be able to avoid having those errors thrown, but you can change how they’re dealt with.

You should NOT be displaying error messages on a live site. For development I like everything displayed, but after that I
ini_set(‘display_errors’, FALSE);
(or better yet in your config if you can).

And I don’t turn off/turn down error_reporting, but use a custom error handler.