Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why the T in PHPs unexpected T_VARIABLE

Tags:

php

What does the "T" 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 it's not only "VARIABLE".)

like image 791
Martin Thoma Avatar asked Feb 22 '23 19:02

Martin Thoma


1 Answers

"T" stands for "token".

When PHP code is being run, the first step is called "lexical analysis" (or "lexing"). The lexer scans through the input text and produces a list of token objects instead. It's common (in many languages) to use names prefixed with T for these.

The next step is to interpret these tokens, allowing them to be compiled or run directly. This is the first step where PHP cares about the order of tokens (in most cases), and so this is where you get the error.

like image 193
Jeremy Avatar answered Feb 25 '23 12:02

Jeremy