List of Reserved Words
The following is a listing of predefined identifiers in PHP. None of the identifiers listed here should be used as identifiers in any of your scripts unless explicitly noted otherwise. These lists include keywords and predefined variables, constant, and class names. These lists are neither exhaustive nor complete.
The following is a listing of predefined identifiers in PHP. None of the identifiers listed here should be used as identifiers in any of your scripts unless explicitly noted otherwise. These lists include keywords and predefined variables, constant, and class names. These lists are neither exhaustive nor complete.
List of Keywords
These words have special meaning in PHP. Some of them represent things which look like functions, some look like constants, and so on - but they're not, really: they are language constructs. The following words cannot be used as constants, class names, or function names. They are, however, allowed as property, constant, and method names of classes, interfaces, traits and enums, except that class may not be used as constant name.
* readonly may be used as function name.
| __CLASS__ | __DIR__ | __FILE__ | __FUNCTION__ | __LINE__ |
| __METHOD__ | __PROPERTY__ | __NAMESPACE__ | __TRAIT__ |
Predefined Classes
This section lists standard predefined classes. Miscellaneous extensions define other classes which are described in their reference.
Standard Defined Classes
These classes are defined in the standard set of functions included in the PHP build.
DirectoryCreated by
dir().stdClassA generic empty class created as a result of typecasting to object or various standard functions.
__PHP_Incomplete_ClassPossibly created by
unserialize().ExceptionErrorExceptionphp_user_filterClosureThe predefined final class
Closureis used for representing anonymous functions.GeneratorThe predefined final class
Generatoris used for representing generators.ArithmeticErrorAssertionErrorDivisionByZeroErrorErrorThrowableParseErrorTypeError
Special classes
Following identifiers may not be used as a class name as they have special purpose.
selfstaticparent
Constants
List of other reserved words
The following words cannot be used to name a class, interface, trait or enum. Prior to PHP 8.0, they are also prohibited from being used in namespaces.
| parent | self | int | float |
| bool | string | true | false |
| null | void (as of PHP 7.1) | iterable (as of PHP 7.1) | object (as of PHP 7.2) |
| mixed (as of PHP 8.0) | never (as of PHP 8.1) | array (as of PHP 8.5) | callable (as of PHP 8.5) |
The following list of words have had soft reservations placed on them. Whilst they may still be used as class, interface, trait and enum names, usage of them is highly discouraged since they may be used in future versions of PHP.
| enum | resource | numeric |