Why is T in PHP unexpectedly T_VARIABLE

What does “T” mean in this PHP error

Parse error: syntax error, unexpected T_VARIABLE 

mean?

(I know what the error itself means, but I would like to know why this is not only "VARIABLE".)

+4
source share
1 answer

"T" means "token."

When the PHP code runs, the first step is called " lexical analysis " (or "lexing"). The lexer scans the input text and creates a list of tokens instead. This is the usual (in many languages) use of names prefixed with T for them.

The next step is to interpret these tokens, allowing them to be compiled or run directly. This is the first step where PHP takes care of the order of the tokens (in most cases), and therefore you get an error here.

+8
source

All Articles