What is the big difference between PHP and JavaScript?
Can we do website only with PHP (and HTML) or is it absolutely necessary you need JavaScript too?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
PHP runs on the
server.Javascript runs within the
browser(what’s called theclient).They are completely distinct. You can do a website without Javascript; however, any in-browser “scripts” will not run with PHP being given to the browser, since the browser does not understand PHP.
So think about it like this…
Javascript would be part of the response to the browser requesting the mypage.php content. On the server, HTML/Javascript/CSS are considered a special kind of text, and have no bearing on the PHP code itself. PHP is meant to ease the management of outputting HTML/Javascript/CSS to browsers, mostly.
A More Extensive Answer
Server – mypage.php
What the browser (client) sees – http://example.com/mypage.php
Notice the script tags stay as they are, but the PHP tags go away. They are
parsedby the PHP parser on the server-side, before outputting the HTML code (with style and script tags intact) to the browser (client).