Jackson
Jackson

Reputation: 820

PHP: Escaping single quotes in javascript echoed by php?

I have an echo in my php page which has a javascript in it.

it looks like this:

echo '<ons-list-item onclick="fn.load('home.html')" tappable>';

I need to escape the single quotes on fn.load('home.html')

so i did:

 echo '<ons-list-item onclick="fn.load(/'home.html'/)" tappable>';

But that doesn't really work..

could someone please advise on this?

Thanks in advance.

Upvotes: 0

Views: 36

Answers (1)

D3181
D3181

Reputation: 2102

Try using double quotes around "home.html".

Or you need to escape ", so it won't be interpreted as end of string. Use \ to escape the quotes as you said.

Upvotes: 2

Related Questions