0

I have the following code:

    echo ('
    <input onclick='responsiveVoice.speak("Hello World");' type='button' value=' Play'>
    ');

When the code is executed, I get the following error:

Parse error: syntax error, unexpected 'responsiveVoice' (T_STRING) in C:\xampp\htdocs\adiai\ai_main.php on line 70

I noticed that my IDE's colors are also getting 'mixed up'. I have a feeling that it is because of the ';' and several quotation marks within my echo statement.

How am I supposed to fix this?

Thanks!

1 Answers1

2

You have single quotes inside and outside your string which caused javascript to misunderstand. Use double quotes outside instead.

Using the \ symbol could help too

echo ("
<input onclick='responsiveVoice.speak(\"Hello World\")' type='button' value=' Play'>
");