PHP.nl

The Deprecated attribute

The Deprecated attribute

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

E_USER_DEPRECATED

Deprecated``stringnull``message``stringnull``since``messageAn optional message explaining the reason for the deprecation and possible replacement functionality. Will be included in the emitted deprecation message.

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

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

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

unsafe_function();

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

Attributes overviewReflectionFunctionAbstract::isDeprecated``ReflectionClassConstant::isDeprecated``E_USER_DEPRECATED

Documentatie