peterjc Posted December 21, 2007 Share Posted December 21, 2007 I am not an expert in php. I want to use php to print out the script so that it will display on the screen. example: echo '<script type="text/javascript"> the script inside here</script>'; The example above will not print it on the screen instead it will run the code. Could someone tell me how to print the script so that it will display on the screen? Thank Quote Link to comment https://forums.phpfreaks.com/topic/82622-php-echo-problem/ Share on other sites More sharing options...
teng84 Posted December 21, 2007 Share Posted December 21, 2007 http://www.php.net/manual/en/function.htmlentities.php Quote Link to comment https://forums.phpfreaks.com/topic/82622-php-echo-problem/#findComment-420183 Share on other sites More sharing options...
PHP_PhREEEk Posted December 21, 2007 Share Posted December 21, 2007 It can be done, but if you just want the code, view the source once the page is loaded. The javascript text will be right there. PhREEEk Quote Link to comment https://forums.phpfreaks.com/topic/82622-php-echo-problem/#findComment-420185 Share on other sites More sharing options...
roshanbh Posted December 21, 2007 Share Posted December 21, 2007 hey dude do like this <script>your script goes here </script>......< & > will be converted to < and > and will be printed out in the browser Quote Link to comment https://forums.phpfreaks.com/topic/82622-php-echo-problem/#findComment-420290 Share on other sites More sharing options...
btherl Posted December 21, 2007 Share Posted December 21, 2007 What teng84 cryptically referred to is this: echo htmlentities('<script type="text/javascript"> the script inside here</script>'); The call to htmlentities() will protect your code from being interpreted by the browser. Quote Link to comment https://forums.phpfreaks.com/topic/82622-php-echo-problem/#findComment-420297 Share on other sites More sharing options...
jitesh Posted December 21, 2007 Share Posted December 21, 2007 echo "<script type=\"text/javascript\"> the script inside here</script>"; Quote Link to comment https://forums.phpfreaks.com/topic/82622-php-echo-problem/#findComment-420309 Share on other sites More sharing options...
peterjc Posted December 21, 2007 Author Share Posted December 21, 2007 i use the htmlentities() function and it work. thank for all of your help. Quote Link to comment https://forums.phpfreaks.com/topic/82622-php-echo-problem/#findComment-420350 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.