PHP Questions Home | Register | Login
Categories
Arrays
Files
Forms
Creating PDFs
PHP Errors
Functions
Images
MySQL
Numbers
Others
Strings
Website
Unanswered

PHP Forums
Forums Index
MySQL Forum
PHP Forum
Flash/Actionscript
Javascript
Web design

More PHP
PHP Functions
Top Questions
Ask a Question
PHP Interview Questions
PHP Jobs
Ecommerce
IT Questions
Business Websites

Sponsors

sponsor ad
My Salary
PHP Developer Salary
Advertise Here

Can I include Javascript in my PHP code?


Yes, you can use PHP straightforwardly to output JavaScript to the webpage.

Simply use the echo or print statement to do so, as you would with normal text or HTML that you are outputting to the screen.

Here's an example of this in action:

<?php 
echo "<script language=\"JavaScript\">"
echo 
"alert("PHP can write JavaScript you know!");"
echo 
"</script>"
?>



Comment on this Question and Answer >>>

ASK A QUESTION

More other PHP Questions

How do I add comments to my PHP script?

What is the difference between sessions and cookies?

What is the differece between $message and $$message?

Can I spellcheck my text using PHP?

What is the difference between the while and do while loops?



Custom Search