|
|
Anhang J. List of Parser Tokens
Various parts of the PHP language are represented internally by types like
T_SR. PHP outputs identifiers like this one in parse errors, like
"Parse error: unexpected T_SR, expecting ',' or ';' in script.php on line 10."
You're supposed to know what T_SR means. For everybody who doesn't
know that, here is a table with those identifiers, PHP-syntax and
references to the appropriate places in the manual.
Tabelle J-1. Tokens Token | Syntax | Reference |
---|
T_AND_EQUAL | &= | assignment
operators | T_ARRAY | array() | array(), array syntax | T_ARRAY_CAST | (array) | type-casting | T_AS | as | foreach | T_BAD_CHARACTER | | anything below ASCII 32 except \t (0x09), \n (0x0a) and \r (0x0d) | T_BOOLEAN_AND | && | logical operators | T_BOOLEAN_OR | || | logical operators | T_BOOL_CAST | (bool) or (boolean) | type-casting | T_BREAK | break | break | T_CASE | case | switch | T_CHARACTER | | | T_CLASS | class | classes and objects | T_CLOSE_TAG | ?> or %> | | T_COMMENT | // or # | comments | T_CONCAT_EQUAL | .= | assignment
operators | T_CONST | const | | T_CONSTANT_ENCAPSED_STRING | "foo" or 'bar' | string syntax | T_CONTINUE | continue | | T_CURLY_OPEN | | | T_DEC | -- | incrementing/decrementing
operators | T_DECLARE | declare | declare | T_DEFAULT | default | switch | T_DIV_EQUAL | /= | assignment
operators | T_DNUMBER | 0.12, etc | floating point numbers | T_DO | do | do..while | T_DOLLAR_OPEN_CURLY_BRACES | ${ | complex
variable parsed syntax | T_DOUBLE_ARROW | => | array syntax | T_DOUBLE_CAST | (real), (double) or (float) | type-casting | T_ECHO | echo | echo() | T_ELSE | else | else | T_ELSEIF | elseif | elseif | T_EMPTY | empty | empty() | T_ENCAPSED_AND_WHITESPACE | | | T_ENDDECLARE | enddeclare | declare, alternative syntax | T_ENDFOR | endfor | for, alternative syntax | T_ENDFOREACH | endforeach | foreach, alternative syntax | T_ENDIF | endif | if, alternative syntax | T_ENDSWITCH | endswitch | switch, alternative syntax | T_ENDWHILE | endwhile | while, alternative syntax | T_END_HEREDOC | | heredoc
syntax | T_EVAL | eval() | eval() | T_EXIT | exit or die | exit(), die() | T_EXTENDS | extends | extends, classes and objects | T_FILE | __FILE__ | constants | T_FOR | for | for | T_FOREACH | foreach | foreach | T_FUNCTION | function or cfunction | functions | T_GLOBAL | global | variable scope | T_IF | if | if | T_INC | ++ | incrementing/decrementing
operators | T_INCLUDE | include() | include() | T_INCLUDE_ONCE | include_once() | include_once() | T_INLINE_HTML | | | T_INT_CAST | (int) or (integer) | type-casting | T_ISSET | isset() | isset() | T_IS_EQUAL | == | comparison operators | T_IS_GREATER_OR_EQUAL | >= | comparison operators | T_IS_IDENTICAL | === | comparison operators | T_IS_NOT_EQUAL | != or <> | comparison operators | T_IS_NOT_IDENTICAL | !== | comparison operators | T_SMALLER_OR_EQUAL | <= | comparison operators | T_LINE | __LINE__ | constants | T_LIST | list() | list() | T_LNUMBER | 123, 012, 0x1ac, etc | integers | T_LOGICAL_AND | and | logical operators | T_LOGICAL_OR | or | logical operators | T_LOGICAL_XOR | xor | logical operators | T_MINUS_EQUAL | -= | assignment
operators | T_ML_COMMENT | /* and */ | comments | T_MOD_EQUAL | %= | assignment
operators | T_MUL_EQUAL | *= | assignment
operators | T_NEW | new | classes and objects | T_NUM_STRING | | | T_OBJECT_CAST | (object) | type-casting | T_OBJECT_OPERATOR | -> | classes and objects | T_OLD_FUNCTION | old_function | old_function | T_OPEN_TAG | <?php, <? or <% | escaping
from HTML | T_OPEN_TAG_WITH_ECHO | <?= or <%= | escaping
from HTML | T_OR_EQUAL | |= | assignment
operators | T_PAAMAYIM_NEKUDOTAYIM | :: | :: | T_PLUS_EQUAL | += | assignment
operators | T_PRINT | print() | print() | T_REQUIRE | require() | require() | T_REQUIRE_ONCE | require_once() | require_once() | T_RETURN | return | returning values | T_SL | << | bitwise
operators | T_SL_EQUAL | <<= | assignment
operators | T_SR | >> | bitwise
operators | T_SR_EQUAL | >>= | assignment
operators | T_START_HEREDOC | <<< | heredoc
syntax | T_STATIC | static | variable scope | T_STRING | | | T_STRING_CAST | (string) | type-casting | T_STRING_VARNAME | | | T_SWITCH | switch | switch | T_UNSET | unset() | unset() | T_UNSET_CAST | (unset) | (not documented; casts to NULL) | T_USE | use | (not implemented) | T_VAR | var | classes and objects | T_VARIABLE | $foo | variables | T_WHILE | while | while, do..while | T_WHITESPACE | | | T_XOR_EQUAL | ^= | assignment
operators | T_FUNC_C | __FUNCTION__ | constants, since
PHP 4.3.0 | T_CLASS_C | __CLASS__ | constants, since
PHP 4.3.0 |
User Contributed Notes List of Parser Tokens |
|
yomama_AT_ucsd.edu
25-Sep-2002 06:19 |
|
if you get a parse error saying that there was an unexpected
T_ENCAPSED_AND_WHITESPACE, you've probably got an array within double
quoted strings being parsed incorrectly.
For example:
$foo =
$_GET['foo']; echo "foo is $foo"; // works
fine
However,
echo "foo is $_GET['foo']"; // parse
error
Inside double-quoted strings, an identifier found within
square brackets (after a variable, of course) is parsed as a string index.
This identifier must be either a string, another variable, or a number.
Since the single-quote around foo doens't fit (to the parser, anyway) any
of these tokens, you get the parse error.
To remove the error,
remove the single quotes, OR use the curly-brace syntax (recommended, as
it's required for more complex substitution anyway).
echo "foo
is {$_GET['foo']}"; // works echo "foo is $_GET[foo]";
// also works
|
|
php at moechofe dot com
13-Mar-2003 12:25 |
|
echo "foo is $_GET[foo][2]"; // don't works echo "foo is
{$_GET['foo'][2]}"; // works
echo "foo is
".$_GET[foo][2]; // works if "foo" is not a defined
constant
|
|
hellsatan hellsatan at darkblazes dot com
09-Apr-2003 09:00 |
|
I got a "T_ENCAPSED_AND_WHITESPACE" parse error on one of my php
files, and did not understand why.
When I read your post about
this, I first of all tried the {} brackets idea, but found that it did not
work. I then removed all instances of [' '] and replaced them with [ ].
Then it worked.
Satan
|
|
|
| |