Page 1 of 1
can i use javascript inside A PHP document?
Posted: Mon Jul 30, 2007 10:07 am
by icesha
hi. i am currently having problems in using javascript in my PHP document. I saved my webpage as a php file but when i coded the javascript in my php doc nothings happening. So my basic question is that is it allowed to used javascript if my document is in PHP extension name?
please. thank you.
Posted: Mon Jul 30, 2007 10:11 am
by guitarlvr
You can have javascript in your page. consider the following:
Code: Select all
<html>
<script type="text/javascript">
// your javascript code goes here
</script>
<body>
<?php
//your php code goes here
?>
<p>this is some html</p>
</body>
</html>
is your page setup similar? it would help if you could post the code you are using.
Posted: Mon Jul 30, 2007 10:11 am
by miro_igov
PHP is just preprocessor, it outputs HTML so you can use javascript in your php files. You need to output the JS code too.