PHP application stopped working after PHP upgrade to 5.3 (T_GOTO)

Written by - 0 comments

Published on - Listed in PHP Linux


Funny issue on a PHP application which was previously running on PHP 5.2 and now since on PHP 5.3. Right after the migration the application stopped working.

Once I set the display_errors flag to 'on', the following error appeared:

Parse error: syntax error, unexpected T_GOTO, expecting T_STRING or '(' in /var/www/www.example.com/html/de/myapp/inc/inc_functions.php on line 174

In the mentioned php script on line 174 and found this:

function goto ($url){
echo "<script language=\"JavaScript\">
      window.setTimeout('window.location.href=\"$url\"','10')
      </script>";}

Doesn't look wrong to me, or does it?

Actually since PHP 5.3 the function name "goto" is now a reserved function and cannot be used as a function name anymore (source).

So I simply renamed the function to goto2:

function goto2 ($url){
echo "<script language=\"JavaScript\">
      window.setTimeout('window.location.href=\"$url\"','10')
      </script>";}

Of course I needed to replace the function name wherever it was used in this particular php application (around 15 different php scripts). After this change the web-application was running fine again.


Add a comment

Show form to leave a comment

Comments (newest first)

No comments yet.