What Does PHP Do with Deprecated Functions

What does PHP do with deprecated functions?

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 notices PHP 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)

How to deprecate a function in PHP?

If I understand correct, you want to trigger an error when a built-in PHP function is used? In that case, take a look at the Override Function function.

function is deprecated in php 7.2.2, how to fix it?

"Not working" is something different than "deprecated". Not sure what version you were upgrading from, but using the $con variable inside the function will not work without either passing it to the function or defining it global inside the function.

function selectLecturer($lecturer_id) {
global $con;

$sql=mysqli_query($con,"SELECT * FROM lecturer WHERE id='$lecturer_id'");
$row=mysqli_fetch_array($sql);
echo $row['name']." ".$row['surname'];
}

Why do frameworks and such deprecate functions instead of just updating them?

When the design of the function has changed, they want to offer a period of time where both old and new functions are offered (a transition time) and then at some future date, the old version is removed. This could not be done if they kept the same name for the new behavior. .live() and .on() take different arguments and work differently. .on() is more powerful and can be made to simulate .live() if desired, but the two are not compatible without changing the calling code.

Introducing the new feature with a new behavior, also simplifies the documentation process since it's completely clear which behavior is documented (by which name it's writing about).

And, when old code includes the newest latest version that no longer supports the old way of doing things, it is much clearer why things don't work when .live() is not even present than if it was present, but had the wrong behavior.

And, old behaviors like .live() are eventually removed from the code because they are a bad way of doing things (that can lead to significant inefficiencies) so jQuery wants everyone to eventually stop using them. Removing it from future versions is a way of forcing it's usage to decline and eventually go away. The transition period gives the developers a significant amount of time to learn about the need to change and to implement/test the change.

Deprecated functions and methods in php update

Deprecated features are documented in the appendices of the PHP manual (see the "Migrating from..." chapters). Meanwhile, you can get them ignored in legacy code by setting an appropriate error_reporting level (one that does not include the E_DEPRECATED flag).



Related Topics



Leave a reply



Submit