can i use javascript inside A PHP document?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Locked
icesha
Forum Newbie
Posts: 11
Joined: Tue May 01, 2007 3:15 am

can i use javascript inside A PHP document?

Post 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.
User avatar
guitarlvr
Forum Contributor
Posts: 245
Joined: Wed Mar 21, 2007 10:35 pm

Post 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.
miro_igov
Forum Contributor
Posts: 485
Joined: Fri Mar 31, 2006 5:06 am
Location: Bulgaria

Post 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.
Locked