php-doc-en/appendices/reserved.xml
2021-04-23 11:35:26 +03:00

629 lines
16 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<appendix xml:id="reserved" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>List of Reserved Words</title>
<para>
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.
</para>
<sect1 xml:id="reserved.keywords">
<title>List of Keywords</title>
<simpara>
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.
</simpara>
<simpara>
As of PHP 7.0.0 these keywords are allowed as property, constant, and
method names of classes, interfaces and traits, except that
<literal>class</literal> may not be used as constant name.
</simpara>
<table>
<title>PHP Keywords</title>
<tgroup cols="5">
<tbody>
<row>
<entry>
<function>__halt_compiler</function>
</entry>
<entry>
<link linkend="language.oop5.abstract">abstract</link>
</entry>
<entry>
<link linkend="language.operators.logical">and</link>
</entry>
<entry>
<function>array</function>
</entry>
<entry>
<link linkend="control-structures.foreach">as</link>
</entry>
</row>
<row>
<entry>
<link linkend="control-structures.break">break</link>
</entry>
<entry>
<link linkend="language.types.callable">callable</link> (as of PHP 5.4)
</entry>
<entry>
<link linkend="control-structures.switch">case</link>
</entry>
<entry>
<link linkend="language.exceptions">catch</link>
</entry>
<entry>
<link linkend="language.oop5.basic.class">class</link>
</entry>
</row>
<row>
<entry>
<link linkend="language.oop5.cloning">clone</link>
</entry>
<entry>
<link linkend="language.oop5.constants">const</link>
</entry>
<entry>
<link linkend="control-structures.continue">continue</link>
</entry>
<entry>
<link linkend="control-structures.declare">declare</link>
</entry>
<entry>
<link linkend="control-structures.switch">default</link>
</entry>
</row>
<row>
<entry>
<function>die</function>
</entry>
<entry>
<link linkend="control-structures.do.while">do</link>
</entry>
<entry>
<function>echo</function>
</entry>
<entry>
<link linkend="control-structures.else">else</link>
</entry>
<entry>
<link linkend="control-structures.elseif">elseif</link>
</entry>
</row>
<row>
<entry>
<function>empty</function>
</entry>
<entry>
<link linkend="control-structures.declare">enddeclare</link>
</entry>
<entry>
<link linkend="control-structures.alternative-syntax">endfor</link>
</entry>
<entry>
<link linkend="control-structures.alternative-syntax">endforeach</link>
</entry>
<entry>
<link linkend="control-structures.alternative-syntax">endif</link>
</entry>
</row>
<row>
<entry>
<link linkend="control-structures.alternative-syntax">endswitch</link>
</entry>
<entry>
<link linkend="control-structures.alternative-syntax">endwhile</link>
</entry>
<entry>
<function>eval</function>
</entry>
<entry>
<function>exit</function>
</entry>
<entry>
<link linkend="language.oop5.basic.extends">extends</link>
</entry>
</row>
<row>
<entry>
<link linkend="language.oop5.final">final</link>
</entry>
<entry>
<link linkend="language.exceptions">finally</link> (as of PHP 5.5)
</entry>
<entry>
<link linkend="functions.arrow">fn</link> (as of PHP 7.4)
</entry>
<entry>
<link linkend="control-structures.for">for</link>
</entry>
<entry>
&foreach;
</entry>
</row>
<row>
<entry>
<link linkend="functions.user-defined">function</link>
</entry>
<entry>
<link linkend="language.variables.scope">global</link>
</entry>
<entry>
<link linkend="control-structures.goto">goto</link> (as of PHP 5.3)
</entry>
<entry>
<link linkend="control-structures.if">if</link>
</entry>
<entry>
<link linkend="language.oop5.interfaces">implements</link>
</entry>
</row>
<row>
<entry>
<function>include</function>
</entry>
<entry>
<function>include_once</function>
</entry>
<entry>
<link linkend="language.operators.type">instanceof</link>
</entry>
<entry>
<link linkend="language.oop5.traits.conflict">insteadof</link> (as of PHP 5.4)
</entry>
<entry>
<link linkend="language.oop5.interfaces">interface</link>
</entry>
</row>
<row>
<entry>
<function>isset</function>
</entry>
<entry>
<function>list</function>
</entry>
<entry>
<link linkend="control-structures.match">match</link> (as of PHP 8.0)
</entry>
<entry>
<link linkend="language.namespaces">namespace</link> (as of PHP 5.3)
</entry>
<entry>
<link linkend="language.oop5.basic.new">new</link>
</entry>
</row>
<row>
<entry>
<link linkend="language.operators.logical">or</link>
</entry>
<entry>
<function>print</function>
</entry>
<entry>
<link linkend="language.oop5.visibility">private</link>
</entry>
<entry>
<link linkend="language.oop5.visibility">protected</link>
</entry>
<entry>
<link linkend="language.oop5.visibility">public</link>
</entry>
</row>
<row>
<entry>
<function>require</function>
</entry>
<entry>
<function>require_once</function>
</entry>
<entry>
<function>return</function>
</entry>
<entry>
<link linkend="language.variables.scope">static</link>
</entry>
<entry>
<link linkend="control-structures.switch">switch</link>
</entry>
</row>
<row>
<entry>
<link linkend="language.exceptions">throw</link>
</entry>
<entry>
<link linkend="language.oop5.traits">trait</link> (as of PHP 5.4)
</entry>
<entry>
<link linkend="language.exceptions">try</link>
</entry>
<entry>
<function>unset</function>
</entry>
<entry>
<link linkend="language.namespaces">use</link>
</entry>
</row>
<row>
<entry>
<link linkend="language.oop5.properties">var</link>
</entry>
<entry>
<link linkend="control-structures.while">while</link>
</entry>
<entry>
<link linkend="language.operators.logical">xor</link>
</entry>
<entry>
<link linkend="language.generators">yield</link> (as of PHP 5.5)
</entry>
<entry>
<link linkend="control-structures.yield.from">yield from</link> (as of PHP 7.0)
</entry>
</row>
</tbody>
</tgroup>
</table>
<table>
<title>Compile-time constants</title>
<tgroup cols="5">
<tbody>
<row>
<entry>
<link linkend="language.constants.predefined">__CLASS__</link>
</entry>
<entry>
<link linkend="language.constants.predefined">__DIR__</link> (as of PHP 5.3)
</entry>
<entry>
<link linkend="language.constants.predefined">__FILE__</link>
</entry>
<entry>
<link linkend="language.constants.predefined">__FUNCTION__</link>
</entry>
<entry>
<link linkend="language.constants.predefined">__LINE__</link>
</entry>
<entry>
<link linkend="language.constants.predefined">__METHOD__</link>
</entry>
</row>
<row>
<entry>
<link linkend="language.namespaces.nsconstants">__NAMESPACE__</link> (as of PHP 5.3)
</entry>
<entry>
<link linkend="language.constants.predefined">__TRAIT__</link> (as of PHP 5.4)
</entry>
<entry>
</entry>
<entry>
</entry>
<entry>
</entry>
<entry>
</entry>
</row>
</tbody>
</tgroup>
</table>
</sect1>
<sect1 xml:id="reserved.classes">
<title>Predefined Classes</title>
<para>
This section lists standard predefined classes. Miscellaneous extensions
define other classes which are described in their reference.
</para>
<sect2 xml:id="reserved.classes.standard">
<title>Standard Defined Classes</title>
<simpara>
These classes are defined in the standard set of functions included
in the PHP build.
</simpara>
<variablelist>
<varlistentry>
<term><classname>Directory</classname></term>
<listitem>
<simpara>
Created by <function>dir</function>.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><classname>stdClass</classname></term>
<listitem>
<simpara>
Created by <link linkend="language.types.object.casting">typecasting
to object</link>.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><classname>__PHP_Incomplete_Class</classname></term>
<listitem>
<simpara>
Possibly created by <function>unserialize</function>.
</simpara>
</listitem>
</varlistentry>
</variablelist>
</sect2>
<sect2 xml:id="reserved.classes.php5">
<title>Predefined classes as of PHP 5</title>
<simpara>
These additional predefined classes were introduced in
PHP 5.0.0.
</simpara>
<variablelist>
<varlistentry>
<term><classname>Exception</classname></term>
<listitem>
<simpara>
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><classname>ErrorException</classname></term>
<listitem>
<simpara>
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><classname>php_user_filter</classname></term>
<listitem>
<simpara>
</simpara>
</listitem>
</varlistentry>
</variablelist>
</sect2>
<sect2 xml:id="reserved.classes.closure">
<title>Closure</title>
<simpara>
The predefined final class <classname>Closure</classname> was introduced
in PHP 5.3.0. It is used for representing <link
linkend="functions.anonymous">anonymous functions</link>.
</simpara>
<simpara>
For more information, see its <link linkend="class.closure">class
page</link>.
</simpara>
</sect2>
<sect2 xml:id="reserved.classes.generator">
<title>Generator</title>
<simpara>
The predefined final class <classname>Generator</classname> was introduced
in PHP 5.5.0. It is used for representing <link
linkend="language.generators">generators</link>.
</simpara>
<simpara>
For more information, see its <link linkend="class.generator">class
page</link>.
</simpara>
</sect2>
<sect2 xml:id="reserved.classes.php7">
<title>Predefined interfaces and classes as of PHP 7</title>
<simpara>
These additional predefined interfaces and classes were introduced in
PHP 7.0.0.
</simpara>
<variablelist>
<varlistentry>
<term><classname>ArithmeticError</classname></term>
<listitem>
<simpara>
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><classname>AssertionError</classname></term>
<listitem>
<simpara>
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><classname>DivisionByZeroError</classname></term>
<listitem>
<simpara>
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><classname>Error</classname></term>
<listitem>
<simpara>
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><classname>Throwable</classname></term>
<listitem>
<simpara>
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><classname>ParseError</classname></term>
<listitem>
<simpara>
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><classname>TypeError</classname></term>
<listitem>
<simpara>
</simpara>
</listitem>
</varlistentry>
</variablelist>
</sect2>
<sect2 xml:id="reserved.classes.special">
<title>Special classes</title>
<simpara>
Following identifiers may not be used as a class name as they have
special purpose.
</simpara>
<variablelist>
<varlistentry>
<term><classname>self</classname></term>
<listitem>
<simpara>
<link linkend="language.oop5.paamayim-nekudotayim">Current
class</link>.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><classname>static</classname></term>
<listitem>
<simpara>
<link linkend="language.oop5.late-static-bindings">Current class in
runtime</link>.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><classname>parent</classname></term>
<listitem>
<simpara>
<link linkend="language.oop5.paamayim-nekudotayim">Parent
class</link>.
</simpara>
</listitem>
</varlistentry>
</variablelist>
</sect2>
</sect1>
&appendices.reserved.constants;
<sect1 xml:id="reserved.other-reserved-words">
<title>List of other reserved words</title>
<simpara>
The following words cannot be used to name a class, interface or trait, and
they are also prohibited from being used in namespaces.
</simpara>
<para>
<table>
<title>Reserved words</title>
<tgroup cols="5">
<tbody>
<row>
<entry>
int (as of PHP 7)
</entry>
<entry>
float (as of PHP 7)
</entry>
<entry>
bool (as of PHP 7)
</entry>
<entry>
string (as of PHP 7)
</entry>
</row>
<row>
<entry>
true (as of PHP 7)
</entry>
<entry>
false (as of PHP 7)
</entry>
<entry>
null (as of PHP 7)
</entry>
<entry>
void (as of PHP 7.1)
</entry>
</row>
<row>
<entry>
iterable (as of PHP 7.1)
</entry>
<entry>
object (as of PHP 7.2)
</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
<para>
The following list of words have had soft reservations placed on them.
Whilst they may still be used as class, interface, and trait names (as well
as in namespaces), usage of them is highly discouraged since they may be
used in future versions of PHP.
</para>
<para>
<table>
<title>Soft reserved words</title>
<tgroup cols="5">
<tbody>
<row>
<entry>
resource (as of PHP 7)
</entry>
<entry>
mixed (as of PHP 7)
</entry>
<entry>
numeric (as of PHP 7)
</entry>
<entry>
</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
</sect1>
</appendix>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->