PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Classes pré-definidas> <Lista de funções sinônimas (aliases)
Last updated: Fri, 15 Aug 2008

view this page in

Palavras reservadas do PHP

Índice

Esta é uma lista de identificadores predefinidos do PHP. Nenhum dos nomes listados aqui pode ser utilizado como seus identificadores em nenhum script. Esta lista inclui palavras-chave e variáveis pré-definidas, constantes e nomes de classes. Esta lista ainda não está completa.

Lista de palavras-chave (keywords)

Estas palavras tem um significado especial no PHP. Algumas delas representam coisas que parecem funções, algumas parecem constantes mas na verdade não o são realmente: elas são construtores de linguagem. Você não pode usar nenhuma das seguintes palavras como constantes, nomes de classes, de funções ou de métodos. Utilizar como nome de variáveis geralmente não causa erros, mas pode levar a confusão.

Palavras-chave do PHP
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 (PHP 5) php_user_filter (PHP 5)
interface (PHP 5) implements (PHP 5) instanceof (no PHP 5) public (PHP 5) private (PHP 5)
protected (PHP 5) abstract (PHP 5) clone (PHP 5) try (PHP 5) catch (PHP 5)
throw (PHP 5) cfunction (PHP 4 somente) old_function (PHP 4 somente) this (PHP 5) final (no PHP 5)
__NAMESPACE__ (no PHP 5.3) namespace (no PHP 5.3) goto (PHP 6 somente) __DIR__ (no PHP 5.3)


add a note add a note User Contributed Notes
Palavras reservadas do PHP
SR
04-Oct-2007 10:53
[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.
londonx at gmail dot com
05-Mar-2007 02:14
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.
01-Nov-2006 04: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?)
10-Jan-2006 03:41
I don't see the boolean constants 'true' and 'false' listed among the reserved words/keywords/constants.

 
show source | credits | stats | sitemap | contact | advertising | mirror sites