Insert Simple Javascript in PHP
Aug 14, 2008 I programming.Today i try to add a simple javascript code to SMF forum. SMF use PHP and i should insert that code between the php code of SMF. but this simple work did not finish easily. the code was
<script language=’javascript’ src=’http://www.kingads.ir/b/?u=377&a=1&b=0′></script>
the php use // for comments. so i try to change ‘ in the src with ” like
src=”http://www.kingads.ir/b/?u=377&a=1&b=0″
but still i have the problem and begin search to how put javascript code in PHP. most of them said you should use “echo” like this
<?php
echo”<script language=’javascript’>
</script>
“;
?>
but again nothing happened and my script did not work correctly. until i look at google analytic code that i use in my SMF forum and found the google use type=”text/javascript” instead of language=’javascript’. so i change this in my script and now it’s work fine. also did not forget to change ‘ with “. the final script is here
<script type=”text/javascript” src=”http://www.kingads.ir/b/?u=377&a=1&b=0″></script>
