Added note about variable naming.

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@22177 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Torben Wilson 2000-03-30 21:10:49 +00:00
parent 9a4f6de16e
commit 0b6e57d669

View file

@ -4,17 +4,40 @@
<sect1 id="language.variables.basics">
<title>Basics</title>
<para>
<simpara>
Variables in PHP are represented by a dollar sign followed by the
name of the variable. The variable name is case-sensitive.
</simpara>
<para>
Variable names follow the same rules as other labels in PHP. A
valid variable name starts with a letter or underscore, followed
by any number of letters, numbers, or underscores. As a regular
expression, it would be expressed thus:
'[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*'
</para>
<note>
<simpara>
For our purposes here, a letter is a-z, A-Z, and the ASCII
characters from 127 through 255 (0x7f-0xff).
</simpara>
</note>
<para>
<informalexample>
<programlisting role="php">
$var = "Bob";
$Var = "Joe";
echo "$var, $Var"; // outputs "Bob, Joe"
echo "$var, $Var"; // outputs "Bob, Joe"
$4site = 'not yet'; // invalid; starts with a number
$_4site = 'not yet'; // valid; starts with an underscore
$täyte = 'mansikka'; // valid; 'ä' is ASCII 228.
</programlisting>
</informalexample>
</para>
<para>
In PHP3, variables are always assigned by value. That is to say,
when you assign an expression to a variable, the entire value of