Take the State of PHP 2026 Survey →

New error level E_USER_DEPRECATED View as Markdown

Implemented (PHP 5.3)
Authors
Lars Strojny lstrojny@php.net
Date
2008-07-18
Version
1.0
Source
wiki.php.net/rfc/e-user-deprecated-warning

Discussions on the mailing list

[RFC] E_USER_DEPRECATED
by Lars Strojny · 10 messages

RFC text

Copied from wiki.php.net, last synchronized Oct 13, 2026 11:52 UTC

Introduction

In 5.3 we introduced E_DEPRECATED to mark internal functions/classes/syntax elements as deprecated with a separate error level. The same deprecation process applies for user level code. That's why we should introduce E_USER_DEPRECATED similar to the already present user space levels E_USER_WARNING, E_USER_NOTICE and E_USER_ERROR.

Proposal and Patch

Use cases

UC 1: Deprecation warning in a constructor

<?php
class Foo
{
    public function __construct()
    {
        trigger_error('Use Bar instead', E_USER_DEPRECATED);
    }
}

UC 2: Deprecation warning at function call

<?php
function do_something()
{
    trigger_error('Use do_something_else() instead', E_USER_DEPRECATED);
}

UC 3: Deprecation warning when a file is included

<?php
// MY_FUNKY_LIBRARY
trigger_error('Use non-funky library', E_USER_DEPRECATED);
 
...