Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does PHP do with deprecated functions?

Tags:

php

deprecated

Getting these errors "Deprecated: Assigning the return value of new by reference is deprecated..."

While I know what deprecated function means, but I am not very clear that what PHP does to them? Still execute them as usual? So at this point for this function, does PHP silently assign memory location for the variable or still using reference pointer?

EDIT - thanks for the answers, I asked this question because we are using adodb_lite and the library has not corrected error.

like image 643
James Lin Avatar asked Jul 25 '11 21:07

James Lin


People also ask

What happens when a function is deprecated?

Deprecated in general means "don't use it". A deprecated function may or may not work, but it is not guaranteed to work.

How do I fix deprecated errors in PHP?

error_reporting(E_ALL ^ (E_NOTICE | E_WARNING | E_DEPRECATED)); This will stop showing notices, warnings, and deprecated errors. Save this answer.


1 Answers

Deperecated functions still exist and you get the warning. So they work as expected. However in a future version they might disappear.

That's the same for other deprecated language features which you sometimes get notices about. It's a way to signal changes to users which have code based on an older PHP version.

Normally the deprecated features get removed after some time, but it's not predictable how long this takes. I know of at least one case where a once deprecated feature was un-deprecated later on. However, I think that's exceptional.

So if you see these warnings, update the code. Most often the PHP documentation has more information why something has been deprecated and what to do. Most often it's an improvement (e.g. in security), so you really should deal with these warnings if you care about the code.

Edit: I think it's noteworthy in this context to look for strict standards noticesPHP Manual as well. They are somewhat related because these notices are useful hints for changes in the language as well.

Enabling E_STRICT during development has some benefits. STRICT messages will help you to use the latest and greatest suggested method of coding, for example warn you about using deprecated functions.

(from the PHP Manual link above)

like image 186
hakre Avatar answered Sep 28 '22 08:09

hakre