Question

I want to write an onclick function inside quotes but it throws error

$ad_div1='<div onclick="window.location="\"/"http://wwww/google.com"\"/"">xxx</div>';

How to add these quotes correctly ?

Was it helpful?

Solution

Try with this:

$ad_div1='<div onclick="window.location=\'http://wwww/google.com\'">xxx</div>';

If you need dynamic url use,

$ad_div1='<div onclick="window.location=\''.$url.'\'">xxx</div>';
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top