Search code examples
phpinternal-server-errorbrackets

500 - Internal Server Error with extra pair of brackets


I have been looking for an error in my code since an hour. This was the error:

Writing:

if(isset(($_POST['to'])))

instead of

if(isset($_POST['to']))

I don't get why is this extra pair of brackets causing an Internal Server Error.

I don't think putting brackets around a variable never changes its value. I mean,

$a = $b;
$c = ($b);

$a==$c; //True

I am curious as to know why is it an error?

Thank you.

EDIT:

The above error was occurring for normal variable also.


Solution

  • This is because isset is not a function but a language construct; as such, its definition can be found in the language parser.

    T_ISSET '(' isset_variables ')' { $$ = $3; }
    

    It only expects one pair of braces; passing another pair will cause a parse error.