<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/reserved.attributes.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'en',
  ),
  'this' => 
  array (
    0 => 'class.deprecated.php',
    1 => 'Deprecated',
    2 => 'The Deprecated attribute',
  ),
  'up' => 
  array (
    0 => 'reserved.attributes.php',
    1 => 'Predefined Attributes',
  ),
  'prev' => 
  array (
    0 => 'allowdynamicproperties.construct.php',
    1 => 'AllowDynamicProperties::__construct',
  ),
  'next' => 
  array (
    0 => 'deprecated.construct.php',
    1 => 'Deprecated::__construct',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'language/predefined/attributes/deprecated.xml',
  ),
  'history' => 
  array (
  ),
  'extra_header_links' => 
  array (
    'rel' => 'alternate',
    'href' => '/manual/en/feeds/class.deprecated.atom',
    'type' => 'application/atom+xml',
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="class.deprecated" class="reference">
 <h1 class="title">The Deprecated attribute</h1>
 

 <div class="partintro"><p class="verinfo">(PHP 8 &gt;= 8.4.0)</p>

  <div class="section" id="deprecated.intro">
   <h2 class="title">Introduction</h2>
   <p class="simpara">
    This attribute is used to mark functionality as deprecated.
    Using deprecated functionality will cause an <strong><code><a href="errorfunc.constants.php#constant.e-user-deprecated">E_USER_DEPRECATED</a></code></strong> error to be emitted.
   </p>
  </div>

  <div class="section" id="deprecated.synopsis">
   <h2 class="title">Class synopsis</h2>

   <div class="classsynopsis"><div class="classsynopsisinfo">
    
     <span class="attribute"><a href="class.attribute.php">#[\Attribute]</a> </span><br>
     <span class="modifier">final</span>
     <span class="modifier">class</span> <strong class="classname"><strong class="classname">Deprecated</strong></strong>
     {</div>

    <div class="classsynopsisinfo classsynopsisinfo_comment">/* Properties */</div>
    <div class="fieldsynopsis">
     <span class="modifier">public</span>
     <span class="modifier">readonly</span>
     <span class="type">?</span><span class="type"><span class="type"><a href="language.types.string.php" class="type string">string</a></span><span class="type"></span></span>
      <var class="varname"><a href="class.deprecated.php#deprecated.props.message">$<var class="varname">message</var></a></var>;</div>

    <div class="fieldsynopsis"><span class="modifier">public</span>
     <span class="modifier">readonly</span>
     <span class="type">?</span><span class="type"><span class="type"><a href="language.types.string.php" class="type string">string</a></span><span class="type"></span></span>
      <var class="varname"><a href="class.deprecated.php#deprecated.props.since">$<var class="varname">since</var></a></var>;</div>


    <div class="classsynopsisinfo classsynopsisinfo_comment">/* Methods */</div>
    <div class="constructorsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><a href="deprecated.construct.php" class="methodname">__construct</a></span>(<span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.string.php" class="type string">string</a></span></span> <code class="parameter">$message</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>, <span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.string.php" class="type string">string</a></span></span> <code class="parameter">$since</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>)</div>

   }</div>
  </div>

  <div class="section" id="deprecated.props">
   <h2 class="title">Properties</h2>
   <dl>
    
     <dt id="deprecated.props.message"><var class="varname">message</var></dt>
     <dd>
      <p class="para">
       An optional message explaining the reason for the deprecation and possible replacement functionality.
       Will be included in the emitted deprecation message.
      </p>
     </dd>
    
    
     <dt id="deprecated.props.since"><var class="varname">since</var></dt>
     <dd>
       <p class="para">
        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.
       </p>
       <p class="para">
        Functionality that is part of PHP will use Major.Minor as the <var class="varname">since</var> value,
        for example <code class="literal">&#039;8.4&#039;</code>.
       </p>
     </dd>
    
   </dl>
  </div>

  <div class="section">
   <h2 class="title">Examples</h2>
   <div class="informalexample">
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #007700">#[</span><span style="color: #0000BB">\Deprecated</span><span style="color: #007700">(</span><span style="color: #0000BB">message</span><span style="color: #007700">: </span><span style="color: #DD0000">"use safe_replacement() instead"</span><span style="color: #007700">, </span><span style="color: #0000BB">since</span><span style="color: #007700">: </span><span style="color: #DD0000">"1.5"</span><span style="color: #007700">)]<br />function </span><span style="color: #0000BB">unsafe_function</span><span style="color: #007700">()<br />{<br />   echo </span><span style="color: #DD0000">"This is unsafe"</span><span style="color: #007700">, </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #0000BB">unsafe_function</span><span style="color: #007700">();<br /><br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <p class="para">Output of the above example in PHP 8.4 is similar to:</p>
    <div class="example-contents screen">
<div class="cdata"><pre>
Deprecated: Function unsafe_function() is deprecated since 1.5, use safe_replacement() instead in example.php on line 9
This is unsafe
</pre></div>
    </div>
   </div>
  </div>

  <div class="section" id="deprecated.seealso">
   <h2 class="title">See Also</h2>
   <ul class="simplelist">
    <li><a href="language.attributes.php" class="link">Attributes overview</a></li>
    <li><span class="methodname"><a href="reflectionfunctionabstract.isdeprecated.php" class="methodname">ReflectionFunctionAbstract::isDeprecated()</a></span></li>
    <li><span class="methodname"><a href="reflectionclassconstant.isdeprecated.php" class="methodname">ReflectionClassConstant::isDeprecated()</a></span></li>
    <li><strong><code><a href="errorfunc.constants.php#constant.e-user-deprecated">E_USER_DEPRECATED</a></code></strong></li>
   </ul>
  </div>

 </div>

 




<h2>Table of Contents</h2><ul class="chunklist chunklist_reference"><li><a href="deprecated.construct.php">Deprecated::__construct</a> — Construct a new Deprecated attribute instance</li></ul>
</div>
<?php manual_footer($setup); ?>