-3

I am getting an error because of the single quotes that are within the double quotes, and everything is within the single quotes of the $content variable. How can this be solved please?

$content = '

setTimeout("finishAjax('usernameResult', '"+escape(response)+"')", 400);

';
Jay Blanchard
  • 34,243
  • 16
  • 77
  • 119
jbm59er
  • 35
  • 1
  • 3

1 Answers1

0

In order to put a single quote or double quote within a string literal, you have to escape it first. The escape character in PHP is the backslash (\).

$content = "setTimeout(\"finishAjax('usernameResult', '+escape(response)+')\", 400);";

Read more about escape characters HERE.

Coby G.
  • 73
  • 1
  • 10