[web] The difference between javascript and php?

Started by
2 comments, last by elumchaitu 13 years, 9 months ago
What's the difference between them? if any?

And what can you do w/ one that you can't do w/ the other?

They hated on Jeezus, so you think I give a f***?!
Advertisement
PHP = server side scripting.

Basically whenever a browser connects to your webserver to access a PHP page, the server runs the scripts embedded within that page before sending the HTML back to the browser. So it's useful for picking and choosing what you want to send to the user's browser. You can also use it to log user activities (ip address, browser, etc). Can use it for user logins, checkouts, blabla google it.

&#106avascript = client side scripting.<br><br>These scripts run within the user's browser after the page has been downloaded. You can use it to make your pages more interactive and user friendly (remote loading of information without having to refresh the page, images that cycle, hover buttons, drop down menus, etc).
&#106avascript is a scripting language built into the browser. It has direct control over the DOM (the hierarchy of nodes inside your browser that tell your browser where things are placed, how they are styled, and how they interact with each other and the outside world, if at all). &#106avascript does NOT run at "operating system level"; it can't enumerate files &#111;n your hard drive, set up a system scheduled task, or listen for incoming socket connections. It CAN, however, take advantage of any feature your browser exposes.<br><br>PHP, conversely, is a scripting language that (usually) runs as a plugin to a web-server. When your browser hits a web-page that is generated using PHP, the PHP stuff might read into a database, or do something at "operating system level" which would otherwise be impossible without it (or other layers like CGI, Perl, or Java). But since PHP is OS-level, it similarly cannot directly do anything to your web browser (i.e. it can't control the DOM); all it can do is spit out browser-level controls (HTML, CSS, &#106avascript, etc) which your browser understands.<br><br>The two of these work together nicely through various layers. You might have heard of GET or POST requests; these are like a shared array of variables which both your browser and the web-server have access to. Another method is AJAX, which is more or less a real-time connection between a &#106avascript and a PHP script.
PHP is server side language where as &#106avascript is client side language.
PHP is executed on apache server where as &#106avascript is executed using Local Browser.<br>PHP cannot change DOM runtime where as &#106avascript can change DOM runtime.<br><br><!--EDIT--><span class=editedby><!--/EDIT-->[Edited by - Sneftel on August 4, 2010 12:56:33 PM]<!--EDIT--></span><!--/EDIT-->
Visit: www.eluminoustechnologies.com

This topic is closed to new replies.

Advertisement