default keyword in php
256
what does the keyworddefault
in php do? there's no documentation on http://php.net/default, but i get an error when using it as a function name: »unexpected T_DEFAULT, expecting T_STRING«
what does it do/where can i find information about it?
Answer
Solution:
default
is part of theswitch
statement:Answer
Solution:
The
default
keyword is used in the:
The default case matches anything that wasn’t matched by the other cases.
Answer
Solution:
Adding to others answers:
default
is a PHP keyword and keywords cannot be used as function name.When you try:
PHP expects to see a
T_STRING
( an identifier) after the keywordfunction
but sees aT_DEFAULT
and flags a parse/syntax error: