Aiiron Posted February 8, 2008 Share Posted February 8, 2008 Hey guys, I am new here (and somewhat new to coding in general, though I am getting the hang of it). I searched php help forums on Google and ended up here. ANYWAY... I really hope you guys can help me out, I'd love to contribute to this forum every day Okay, on to my question... Is there any way that I can ECHO a variable into another variable? I don't mean like $var = $var2 (that would be pointless), I mean something like $var = echo $var2. Is there a function for that? The reason that I need to do this is... My variable contains javascript, like so: $url='http://www.esnips.com/nsdoc/'. $file .'<script type="text/javascript"> document.write("/?id=" + new Date().getTime() + "")</script>'; The javascript is to generate "id". I want to include that variable in another function like include($url); and similar situations without it literally showing the javascript. If I run the include command for this I get: http://www.esnips.com/nsdoc/XXXXXXXXX/<script type="text/javascript"> document.write("/?id=" + new Date().getTime() + "")</script> But if I echo it I get: http://www.esnips.com/nsdoc/XXXXXXXXX/?id=XXXXXXXX (which is how it should be) So is there any way I can ECHO the variable into an include situation or another variable without it taking the javascript literally? Thanks so much in advance. Quote Link to comment https://forums.phpfreaks.com/topic/90138-quick-php-question/ Share on other sites More sharing options...
Aiiron Posted February 8, 2008 Author Share Posted February 8, 2008 anyone? Quote Link to comment https://forums.phpfreaks.com/topic/90138-quick-php-question/#findComment-462222 Share on other sites More sharing options...
schilly Posted February 8, 2008 Share Posted February 8, 2008 Maybe I don't understand what you're trying to do but why are you using Javascript? $url='http://www.esnips.com/nsdoc/'. $file .'?id=' . time(); Quote Link to comment https://forums.phpfreaks.com/topic/90138-quick-php-question/#findComment-462231 Share on other sites More sharing options...
Aiiron Posted February 9, 2008 Author Share Posted February 9, 2008 Maybe I don't understand what you're trying to do but why are you using Javascript? $url='http://www.esnips.com/nsdoc/'. $file .'?id=' . time(); I have to in order to generate the ID (it fetches functions from another file) -- any clue how to echo a variable in a variable, though? Quote Link to comment https://forums.phpfreaks.com/topic/90138-quick-php-question/#findComment-462244 Share on other sites More sharing options...
nethnet Posted February 9, 2008 Share Posted February 9, 2008 What you're trying to do (and I may be wrong, but I'm pretty sure I'm not) is unfeasible, as PHP is a server-side language and JS is client-side. Therefore, all of your PHP is parsed before there is any output to the browser, while JS is actually part of the output. If all you're doing is getting the time, do what schilly recommended, as use the PHP function time(). Theo Quote Link to comment https://forums.phpfreaks.com/topic/90138-quick-php-question/#findComment-462255 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.