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? Quote 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']}\";"; Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.