pachelbel101 Posted April 19, 2007 Share Posted April 19, 2007 Good evening, How do you keep braces inside of a string? I'm attempting to store a string of javascript into a variable. That string of javascript contains braces, and everything between and including the braces is not showing up in the string. I believe it's interpreting those braces as variable-enclosers, but they aren't. I have tried escaping them (\{), doubling them ({{), putting them in single quotes instead of double quotes, and every time I lose everything between the braces. How do I keep braces inside of a string in PHP? Thanks for your help, this is killing me! Link to comment https://forums.phpfreaks.com/topic/47675-storing-a-string-of-javascript-dropping-everything-between/ Share on other sites More sharing options...
kenrbnsn Posted April 19, 2007 Share Posted April 19, 2007 Please post the code that is giving you problems between tags. Ken Link to comment https://forums.phpfreaks.com/topic/47675-storing-a-string-of-javascript-dropping-everything-between/#findComment-232814 Share on other sites More sharing options...
pachelbel101 Posted April 19, 2007 Author Share Posted April 19, 2007 $slideshowJavascriptCode = "<script>setTimeout( function() { window.location='".$config['baseurl']."/index.php"';}, 30000 );</script>"; It just winds up storing this in the variable: <script>setTimeout( function() , 30000);</script> Link to comment https://forums.phpfreaks.com/topic/47675-storing-a-string-of-javascript-dropping-everything-between/#findComment-232817 Share on other sites More sharing options...
kenrbnsn Posted April 19, 2007 Share Posted April 19, 2007 You have some mis-matched quote in the line: <?php $slideshowJavascriptCode = "<script>setTimeout( function() { window.location='".$config['baseurl']."/index.php"';}, 30000 );</script>"; ?> Try changing it to: <?php $slideshowJavascriptCode = '<script>setTimeout( function() { window.location="'.$config['baseurl'].'/index.php";}, 30000 );</script>'; ?> Ken Link to comment https://forums.phpfreaks.com/topic/47675-storing-a-string-of-javascript-dropping-everything-between/#findComment-232823 Share on other sites More sharing options...
pachelbel101 Posted April 19, 2007 Author Share Posted April 19, 2007 Sorry, the quote wasn't wrong - I accidentally left it there when I removed some meaningless URL garbage off the end. Also, I figured out a solution - if I wrap to the next line anywhere in the middle of the quote, then it doesn't try to interpolate the {} Thanks for your help! Link to comment https://forums.phpfreaks.com/topic/47675-storing-a-string-of-javascript-dropping-everything-between/#findComment-232835 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.