Index: phpdoc/en/language/types.xml
diff -u phpdoc/en/language/types.xml:1.18 phpdoc/en/language/types.xml:1.19
--- phpdoc/en/language/types.xml:1.18 Tue May 8 16:34:05 2001
+++ phpdoc/en/language/types.xml Thu May 10 11:01:04 2001
@@ -11,6 +11,11 @@
+ booleans
+
+
+
+
floating-point numbers
@@ -49,8 +54,15 @@
information, see the section on Type Juggling.
+
+
+ Booleans
+
+ This is the simpelest. Either TRUE or FALSE.
+
+
-
+ Integers
Integers can be specified using any of the following syntaxes:
@@ -131,15 +143,15 @@
\n
- linefeed (LF or 0x0A in ASCII)
+ linefeed (LF or 0x0A (10) in ASCII)\r
- carriage return (CR or 0x0D in ASCII)
+ carriage return (CR or 0x0D (13) in ASCII)\t
- horizontal tab (HT or 0x09 in ASCII)
+ horizontal tab (HT or 0x09 (9) in ASCII)\\
@@ -293,7 +305,126 @@
-
+
+ String parsing
+
+
+ When a string is specified in double quotes, variables are
+ parsed within it.
+
+
+ There are two types of syntax, a
+ simple
+ one and a
+ complex
+ one.
+ The simple syntax is the most common and convenient, it provides a way
+ to parse a variable, an array-value, or a object-property.
+
+
+ The complex syntax was introduced in PHP 4,
+
+ and can by recognised
+ by the curly braces surrounding the expression.
+
+
+ Simple syntax
+
+ If a $ is encoutered, the parser will
+ greedily take as much tokens as possible to form a valid
+ variable name. Enclose the the variable name in curly
+ braces if you want to explicitely specify the end of the
+ name.
+
+
+
+ $beer = 'Heineken';
+ echo "$beer's taste is great"; // works, "'" is an invalid character for varnames
+ echo "He drunk some $beers"; // won't work, 's' is a valid character for varnames
+ echo "He drunk some ${beer}s"; // works
+
+
+
+ Similary, you can also have an array-index and an
+ object-property parsed. With array-indices, the
+ ']' marks the end of the index, for object-properties
+ the same rules apply as to simple variables, though
+ with object properties there doesn't exist a trick
+ like the one with variables.
+
+
+
+
+
+
+ $fruits = array( 'strawberry' => 'red' , 'banana' => 'yellow' );
+ echo "A banana is $fruits[banana].";
+ echo "This square is $square->width meters broad.";
+ echo "This square is $square->width00 centimeters broad."; // won't work,
+ // for a solution, see the complex syntax.
+
+
+
+
+
+
+ For anything more complex, you should use the complex syntax.
+
+
+
+ Complex (curly) syntax
+
+ I didn't call this complex because the syntax is complex,
+ but because you can include complex expressions this way.
+
+
+ In fact, you can include any value that is in the namespace
+ in strings with this syntax. You simply write the expression
+ the same way as you would outside the string, and then include
+ it in { and }. Since you can't escape '{', this syntax will
+ only be recognised when the $ is immediately following the {.
+ (Use "{\$" to get a literal "{$").
+ Some examples to make it clear:
+
+
+
+ $great = 'fantastic';
+ echo "This is { $great}"; // won't work, outputs: This is { fantastic}
+ echo "This is {$great}"; // works, outputs: This is fantastic
+ echo "This square is {$square->width}00 centimeters broad.";
+ echo "This works: {$arr[4][3]}";
+ echo "This is wrong: {$arr[foo][3]}"; // for the same reason
+ // as $foo[bar] is wrong outside a string.
+
+ echo "You should do it this way: {$arr['foo'][3]}";
+ echo "You can even write {$obj->values[3]->name}";
+ echo "This is the value of the var named $name: {${$name}}";
+
+
+ // this works, but i disencourage its use, since this is NOT
+ // involving functions, rather than mere variables, arrays and objects.
+ $beer = 'Heineken';
+ echo "I'd like to have another {${ strrev('reeb') }}, hips";
+
+
+
+
+
+ String conversion
@@ -655,6 +786,9 @@
(int), (integer) - cast to integer
+ (bool), (boolean) - cast to boolean
+
+ (real), (double), (float) - cast to double
@@ -683,6 +817,37 @@
between certain types. For instance, the following should be
noted.
+
+ When converting to boolean, the following values are considered
+ FALSE:
+
+
+
+ the boolean FALSE
+
+
+ the integer 0 (zero)
+
+
+ the float 0.0 (zero)
+
+
+ the empty string, and the string "0"
+
+
+ an array with zero elements
+
+
+ an object with zero elements
+
+
+
+ Every other value is considered true.
+
+ (-1 is considered TRUE!).
+
+
When casting or forcing a conversion from array to string, the
result will be the word Array. When casting or