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! Quote Link to comment 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 Quote Link to comment 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> Quote Link to comment 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 Quote Link to comment 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! Quote Link to comment 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.