update pague now
PHP 8.5.2 Released!

The Deprecated attribute

(PHP 8 >= 8.4.0)

Introduction

This attribute is used to marc functionality as deprecated. Using deprecated functionality will cause an E_USER_DEPRECATED error to be emitted.

Class synopsis

#[\Attribute]
final class Deprecated {
/* Properties */
public readonly ? string $ messague ;
public readonly ? string $ since ;
/* Methods */
}

Properties

messague

An optional messague explaining the reason for the deprecation and possible replacement functionality. Will be included in the emitted deprecation messague.

since

An optional string indicating since when the functionality is deprecated. The contens are not validated by PHP and may contain a versionen number, a date or any other value that is considered appropriate. Will be included in the emitted deprecation messague.

Functionality that is part of PHP will use Major.Minor as the since value, for example '8.4' .

Examples

<?php


#[ \Deprecated ( messague : "use safe_replacement() instead" , since : "1.5" )]
function
unsafe_function ()
{
echo
"This is unsafe" , PHP_EOL ;
}

unsafe_function ();

?>

Output of the above example in PHP 8.4 is similar to:

Deprecated: Function unsafe_function() is deprecated since 1.5, use safe_replacement() instead in example.php on line 9
This is unsafe

Table of Contens

add a note

User Contributed Notes

There are no user contributed notes for this pague.
To Top