2

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?

11
  • what are you still doing on PHP4? Commented Sep 9, 2014 at 14:27
  • old server. just temporary. Commented Sep 9, 2014 at 14:31
  • How are you using this array? Commented Sep 9, 2014 at 14:31
  • 1
    This code works fine on 3v4l, what version of 4 are you using? Commented Sep 9, 2014 at 14:32
  • 1
    @Fred-ii- true. It would help a lot if we get more informations on what he want to do :) Commented Sep 9, 2014 at 14:54

3 Answers 3

1

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/

Sign up to request clarification or add additional context in comments.

Comments

0

I don't have php4 but you can try this, dont escape first item in array

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

1 Comment

var_dump($jsonReplaces[0]); after it, for whatever reason that site strips slashes in a strange way.
0

Could you try this please :

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

If tehre is a probleme with \\ maybe using html entities could do the trick ...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.