# deprecated

# 

<div data-wrapper="1" role="class">

ENTITY

</div>

<div data-wrapper="1" role="class">

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

</div>

<div data-wrapper="1" role="class">

As of PHP 8.5.0, this attribute can also be applied to traits and to compile-time constants declared outside of a class.

</div>

# 

<div data-wrapper="1" role="class">

ENTITY

</div>

<div data-wrapper="1" role="attribute">

\#\[\Attribute(\Attribute::TARGET_METHOD \| \Attribute::TARGET_FUNCTION \| \Attribute::TARGET_CLASS_CONSTANT \| \Attribute::TARGET_CONSTANT \| \Attribute::TARGET_CLASS)\]

</div>

<div data-wrapper="1" role="class">

final

</div>

<div data-wrapper="1" role="class">

Deprecated

</div>

<div data-wrapper="1" role="comment">

ENTITY

</div>

<div data-wrapper="1" role="class">

public

</div>

<div data-wrapper="1" role="class">

readonly

</div>

<div data-wrapper="1" role="class">

string

</div>

<div data-wrapper="1" role="class">

null

</div>

<div data-wrapper="1" role="class">

message

</div>

<div data-wrapper="1" role="class">

public

</div>

<div data-wrapper="1" role="class">

readonly

</div>

<div data-wrapper="1" role="class">

string

</div>

<div data-wrapper="1" role="class">

null

</div>

<div data-wrapper="1" role="class">

since

</div>

<div data-wrapper="1" role="comment">

ENTITY

</div>

# 

<div data-wrapper="1" role="class">

ENTITY

</div>

<div data-wrapper="1" role="class">

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

`since`  
An 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 `since` value, for example `'8.4'`.

</div>

# 

<div data-wrapper="1" role="class">

ENTITY

</div>

<div class="informalexample" role="class">

```
<?php

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

unsafe_function();

?>

    
```

ENTITY

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

        

</div>

# 

<div data-wrapper="1" role="class">

ENTITY

</div>

| ENTITY | ENTITY |
|----|----|
| 8.5.0 | `Deprecated` can now be applied to traits and to compile-time constants declared outside of a class, the latter through the new `Attribute::TARGET_CONSTANT` target. |

# 

<div data-wrapper="1" role="class">

ENTITY

</div>

<div data-wrapper="1" role="class">

Attributes overview

</div>

<div data-wrapper="1" role="class">

ReflectionFunctionAbstract::isDeprecated

</div>

<div data-wrapper="1" role="class">

ReflectionClassConstant::isDeprecated

</div>

<div data-wrapper="1" role="class">

E_USER_DEPRECATED

</div>

<div data-wrapper="1" role="class">

ENTITY

</div>