I'm trying to put a php variable within a js script that is in a result variable that will be processed with json but i don't get it to work. I know it has something to do with the "" and '' but i can't figure out what it is.
$result["html"] .= "<script type='text/javascript'>setTimeout(function () { window.location='.$config[\"BURL\"].'; }, 2500);</script>";
Edit: whoohoo i got the 15 points to upvote! Thanks u all!
1 Answer 1
You will have to concatenate strings using . and remove the escaping of the quotes for the index, like so:
$result["html"] .= "<script type='text/javascript'>setTimeout(function () { window.location='" . $config["BURL"] . "'; }, 2500);</script>";
answered Dec 11, 2014 at 9:46
RichardBernards
3,0971 gold badge25 silver badges30 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
default
window.location='.$config[\"BURL\"].'"$result['BURL'] = "'" . $config["BURL"] . "'"be preferable? Do the processing of JSON$resultclient side and set timeout by JavScript instead of returning a whole document? Hard to say without knowing what you do, but only as a thought.