function old_function(){ displayAsDeprecated("old_function", "use new_function instead"); // old_function code } function new_function(){ // new_function code } old_function();
class MyClass{ function old_function(){ displayAsDeprecated("MyClass::old_function", "use MyClass::new_function instead"); // old_function code } function new_function(){ // new_function code } } $myObject = new MyClass(); $myObject->old_function();In this example, the old_function() is marked as deprecated inside a class using the displayAsDeprecated() function. When the old_function() inside the class is called, it will display a warning message to the user to use the new_function() instead. Package/Library: The displayAsDeprecated() function is not part of any PHP package or library, it is a built-in PHP function since PHP 7.2.0.