diff --git a/language/variables.xml b/language/variables.xml index 3e57730cfe..26e7386941 100644 --- a/language/variables.xml +++ b/language/variables.xml @@ -4,17 +4,40 @@ Basics - + Variables in PHP are represented by a dollar sign followed by the name of the variable. The variable name is case-sensitive. + + + + 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]*' + + + + + For our purposes here, a letter is a-z, A-Z, and the ASCII + characters from 127 through 255 (0x7f-0xff). + + + + $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. + In PHP3, variables are always assigned by value. That is to say, when you assign an expression to a variable, the entire value of