phpchick Posted December 20, 2011 Share Posted December 20, 2011 The code below works echo '<script language="javascript">'; echo 'top.location.href = "/breaking-news/bsnewsstorygoeshere/";'; echo '</script>'; this also works echo '<script language="javascript">'; echo 'top.location.href = "http://anywebsite.com";'; echo '</script>'; the problem, is I have a URL listed in a url variable that can be retreived via $_GET['url'] my question is how to get that variable into the above code? I've tried echo '<script language="javascript">'; echo "top.location.href = \"$_GET['url']\";"; echo '</script>'; but that doesnt seem to work, can anyone advise? Link to comment https://forums.phpfreaks.com/topic/253550-simple-syntaxing-issue-with-_getvariable/ Share on other sites More sharing options...
KevinM1 Posted December 20, 2011 Share Posted December 20, 2011 When attempting to interpolate an array value in a double quoted string, you need to stick it in curly braces. Example: echo "top.location.href = \"{$_GET['url']}\";"; Link to comment https://forums.phpfreaks.com/topic/253550-simple-syntaxing-issue-with-_getvariable/#findComment-1299753 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.