added an example about valid and invalid constant names

# but every name is valid in fact..


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@159220 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Mehdi Achour 2004-05-21 04:55:23 +00:00
parent 4589e94a92
commit a15274f4d1

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.35 $ -->
<!-- $Revision: 1.36 $ -->
<chapter id="language.constants">
<title>Constants</title>
@ -17,8 +17,31 @@
by any number of letters, numbers, or underscores. As a regular
expression, it would be expressed thusly:
<literal>[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*</literal>
</para>
<para>
<example>
<title>Valid and invalid constant names</title>
<programlisting role="php">
<![CDATA[
<?php
<!-- TODO: Example of valid & invalid constant names -->
// Valid constant names
define("foo", "something");
define("foo2", "something else");
define("foo_bar", "something more")
// Invalid constant names
define("2foo", "something");
// This is valid, but should be avoided:
// PHP may one day provide a magical constant
// that will break your script
define("__foo__", "something");
?>
]]>
</programlisting>
</example>
</para>
<note>
<simpara>