Delicious Bookmark this on Delicious Share on Facebook SlashdotSlashdot It! Digg! Digg

PHP : Appendices : List of Reserved Words

Appendix M. 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. These lists include keywords and predefined variable, constant, and class names. These lists are neither exhaustive or 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. You cannot use any of the following words as constants, class names, function or method names. Using them as variable names is generally OK, but could lead to confusion.

Table M.1. PHP Keywords

and or xor __FILE__ exception (PHP 5)
__LINE__ array() as break case
class const continue declare default
die() do echo() else elseif
empty() enddeclare endfor endforeach endif
endswitch endwhile eval() exit() extends
for foreach function global if
include() include_once() isset() list() new
print() require() require_once() return() static
switch unset() use var while
__FUNCTION__ __CLASS__ __METHOD__ final (as of PHP 5) php_user_filter (as of PHP 5)
interface (as of PHP 5) implements (as of PHP 5) extends public (as of PHP 5) private (as of PHP 5)
protected (as of PHP 5) abstract (as of PHP 5) clone (as of PHP 5) try (as of PHP 5) catch (as of PHP 5)
throw (as of PHP 5) cfunction (PHP 4 only) old_function (PHP 4 only) this (as of PHP 5) namespace (PHP 6 only)
import (PHP 6 only) goto (PHP 6 only)

Code Examples / Notes » reserved


[Editorial note: parent and self are reserved class names. Functions and constants with their names can be declared, but not userspace classes]
true, false and null are not listed because they are globally-defined constants, not reserved words.
No idea about parent or self, though.

01-nov-2006 12:42

Two things:
1. It would be nice for this list to differentiate those reserved words, which are language constructs used *with* parentheses (isset, unset, empty, eval, exit, die, ...) and those rather to be used *without* parentheses (all includes, echo, print, return, ...?)
This would really help define some common coding styles...
2. Do you write NULL, TRUE, FALSE or null, true, false? (I find CAPITAL letters better, however typing them can be annoying so I stick with using all lowercase letters, but what's the standard?)

al dot barrett

The list also seems to be missing both "parent" and "self" as well.


Naming a PHP5 class "variant" (with a constructor called the same) and then making an instance of it using __autoload triggers an error which disappears as soon as the name is changed. This should mean that "variant" is also a reserved word.

10-jan-2006 11:41

I don't see the boolean constants 'true' and 'false' listed among the reserved words/keywords/constants.


I also can't find the NULL keyword in the list. The `extends' keyword is mentioned twice, too.

Change Language

Follow Navioo On Twitter
History of PHP and related projects
Migrating from PHP 5.1.x to PHP 5.2.x
Migrating from PHP 5.0.x to PHP 5.1.x
Migrating from PHP 4 to PHP 5
Migrating from PHP 3 to PHP 4
Migrating from PHP/FI 2 to PHP 3
Debugging PHP
Configure options
php.ini directives
List of Supported Timezones
Extension Categorization
List of Function Aliases
List of Reserved Words
List of Resource Types
List of Supported Protocols/Wrappers
List of Available Filters
List of Supported Socket Transports
PHP type comparison tables
List of Parser Tokens
Userland Naming Guide
eXTReMe Tracker