Quotes closing improperly js

Asked

Viewed 57 times

0

With a file PHP I’m entering code javascript. So I’m using echo'.

echo ' grammar: "\name = s:[0-9a-zA-Z]+ { return s.join(""); }\n\" ';

The problem is you’re making a mistake because inside the s.join("") is closing with quotes from Grammar.

I can’t switch to single quotes inside the Join pq or it would close with echo. I believe I have to try to escape the quotation marks. Someone would know how to do that?

  • I suggest you put the code as you have it in your file, because the way it looked here in the question was not clear. It looks like you have 2 echo but there is no ; to separate them. Anyway, escape is always with \, so escape ' would be \'

1 answer

0


The problem ai is that in this place where ta giving error should be single quotes for the fact that the string passed in the JS is open as double quotes. To avoid conflict with opening quotes from php echo, use a concatenation game like this:

echo ' grammar: "\name = s:[0-9a-zA-Z]+ { return s.join('."''".'); }\n\" ';

Browser other questions tagged

You are not signed in. Login or sign up in order to post.