php8.5
Home/ Manual/ appendices/ List of Reserved Words

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.

__halt_compiler()abstractandarray()as
breakcallablecasecatchclass
cloneconstcontinuedeclaredefault
die()doecho()elseelseif
empty()enddeclareendforendforeachendif
endswitchendwhileeval()exit()extends
finalfinallyfn (as of PHP 7.4)forforeach
functionglobalgotoifimplements
include()include_once()instanceofinsteadofinterface
isset()list()Match (as of PHP 8.0)namespacenew
orprint()privateprotectedpublic
readonly (as of PHP 8.1.0) *require()require_once()return()static
switchthrowtraittryunset()
usevarwhilexoryield
yield from

* 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.

Directory

Created by dir().

stdClass

A generic empty class created as a result of typecasting to object or various standard functions.

__PHP_Incomplete_Class

Possibly created by unserialize().

Exception
ErrorException
php_user_filter
Closure

The predefined final class Closure is used for representing anonymous functions.

Generator

The predefined final class Generator is used for representing generators.

ArithmeticError
AssertionError
DivisionByZeroError
Error
Throwable
ParseError
TypeError

Special classes

Following identifiers may not be used as a class name as they have special purpose.

self

Current class.

static

Current class in runtime.

parent

Parent class.

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.

parentselfintfloat
boolstringtruefalse
nullvoid (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.

enumresourcenumeric

Source: appendices/reserved.xml · from the official PHP manual (php/doc-en)