Search code examples
phpphp4

Parse error PHP4 array


I have the following code

$jsonReplaces = array("\\", "/", "\n", "\t", "\r", "\b", "\f", '"');

and I get the following error message running php4:

Parse error: syntax error, unexpected '/', expecting ')' 

And running php5 is not an option. Any ideas on how to get this working in php4?


Solution

  • I think you have found a bug inside writecodeonline.com . Ive tried various ways of writing and storing something like $jsonReplaces = array("\\", "/", "\n", "\t", "\r", "\b", "\f", '"'); and it gives a failure on every try. Seems like the website can't parse that. Might be some issue with stripslashes() (Just a guess). Ive tried same code in another editor and in my local test environment on PHP 4.4.9 and everything is okay.

    For example try your code here:

    http://sandbox.onlinephpfunctions.com/