mayfliesarescary Posted April 14, 2007 Share Posted April 14, 2007 I am really new at using Javascript and PHP. I read this on how to put javascript into a php document but it really made no sense to me: Answer : You just echo / print the javascript like you would do with html, like: <? echo "<script language=\"JavaScript\">\n"; echo "alert("javascript from php");\n"; echo "</script>"; ?> Basically I need this javascript formatted for a PHP document. Can anyone do this so I can just copy and paste the right code or direct me to a source that can explain this a little better to me? Javascript: <script src="http://www.google-analytics.com/urchin.js" type="text/javascript"> </script> <script type="text/javascript"> _uacct = "UA-SAMPLE"; urchinTracker(); </script> Any help would be very much appreciated. Link to comment https://forums.phpfreaks.com/topic/46978-javascript-in-php-help/ Share on other sites More sharing options...
clown[NOR] Posted April 14, 2007 Share Posted April 14, 2007 try this echo '<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"> </script> <script type="text/javascript"> _uacct = "UA-SAMPLE"; urchinTracker(); </script>'; [code] [/code] Link to comment https://forums.phpfreaks.com/topic/46978-javascript-in-php-help/#findComment-229085 Share on other sites More sharing options...
mayfliesarescary Posted April 15, 2007 Author Share Posted April 15, 2007 Yes, it worked! Thank you so much. So basically you just put the script like this? echo 'JAVASCRIPT CODE'; Link to comment https://forums.phpfreaks.com/topic/46978-javascript-in-php-help/#findComment-229537 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.