Jump to content
  • Advertisement
Sign in to follow this  
Fl4sh

[web] The difference between javascript and php?

This topic is 3002 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

What's the difference between them? if any?

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

Share this post


Link to post
Share on other sites
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.

javascript = client side scripting.

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).

Share this post


Link to post
Share on other sites
javascript 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). javascript does NOT run at "operating system level"; it can't enumerate files on 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.

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, javascript, etc) which your browser understands.

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 javascript and a PHP script.

Share this post


Link to post
Share on other sites
PHP is server side language where as javascript is client side language.
PHP is executed on apache server where as javascript is executed using Local Browser.
PHP cannot change DOM runtime where as javascript can change DOM runtime.

[Edited by - Sneftel on August 4, 2010 12:56:33 PM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!