Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do all PHP parse errors start with "T_"?

I just want to know is whether there is any reason/story behind to use T_ before parse errors like

parse error : unexpected `T_`ELSE in ... blah blah blah  
parse error : Unexpected `T_`IF in ....blah   
parse error : unexpected `T_`VAR  
parse error : unexpected `T_`STRING

and many more.

Can you provide any link for clarification? Also, are there any other prefixes used in error displaying then please share.

like image 689
diEcho Avatar asked Mar 23 '11 13:03

diEcho


2 Answers

T stands for Token.

These errors are telling you that the parser found a token that it didn't expect.

like image 76
SLaks Avatar answered Nov 15 '22 03:11

SLaks


Because those are, from the point of view of a parser, tokens, thus the T_ (that's the same reasoning why error levels start with E_ ...).

like image 35
Alexander Gessler Avatar answered Nov 15 '22 03:11

Alexander Gessler