Difference between Javascript and PHP [closed]

What is the differene b/w php and javascript

Roughly akin to the difference between English and German. They can express largely the same things, but do so in different ways, and you’ll have more luck using English in Germany then German in England.

i know one is server side scripting and the other is browser side

Not really.

PHP is a programming language. It is often used for server side programming, but has uses in general programming too.

JavaScript is a programming language. It is the only language that has a decent level of native support for running in a browser. It has a wide variety of server side implementations (including Node and ASP). It is one of the languages you can use with the Windows Scripting Host. etc.

There are plenty of other languages that can be used for server side web programming too (C# is popular in ASP.NET, I’m rather fond of Perl, there are quite a lot of proponents of Python and Ruby, Java has a strong following, and so on).

That said. El Cheapo hosting which supports PHP is a lot more common than El Cheap hosting which supports other things. Leaving language partisanship aside, the primary disadvantage with it is that El Cheapo hosting is has the You Gets What You Pay For rule.

If we take your question to be about the difference between server side and client side programming though…

but what m asking is that using client side programming i can display alert messages

With client side programming you can manipulate things in the browser without going back to the server. e.g. you can add elements to the document to display a message.

You also have access to APIs provided by the browser, such as the alert() method which will display a message box that isn’t an intrinsic part of the document and Local Storage (which lets you store data in the browser which only that browser will have access to).

You can make HTTP requests to ask the server for things (this is called Ajax).

which i can simply do with server side programming also,without using any function

With server side programming, you can modify the document you are sending to the client, but only at load time.

You can access shared resources (such as the contents of a database that lives on the server).

You don’t have access to things like the alert() method. (Although you can generate program code (usually in JS) that will run client side and will have access to those methods).

so does server side and client side programming are exclusive ,like if i use one then the other one should not be used,or ??

In general, any essential functionality should be handled with server side programming. Build on things that work. Client side programming can break, either because you depend on a feature that isn’t available in the browser the user is using, because a script fails to load, because the user happens to have JavaScript turned off, or because the user is trying something malicious (such as passing data to the server that could cause an XSS or SQL injection problem).

Client side programming, on the other hand, can be used to make things more convenient for the user. You can add animation to indicate that something is happening, check data before it is submitted to the server (saving the time of a round trip), update part of a page periodically, and so on.

Leave a Comment