Viewed   68 times

What is the difference between PHP and Javascript?

I know one is server side scripting and the other is browser side. but what I'm asking is that using Javascript, can I display alert messages,which i can simply do with PHP also,without using any function, or using some if-else combination.

So are PHP and Javascript are exclusive, like if i use one then the other one should not be used, or?



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.

Monday, December 19, 2022

The metacharacter b is an anchor like the caret and the dollar sign. It matches at a position that is called a "word boundary". This match is zero-length.

There are three different positions that qualify as word boundaries:

  • Before the first character in the string, if the first character is a word character.
  • After the last character in the string, if the last character is a word character.
  • Between two characters in the string, where one is a word character and the other is not a word character.

Simply put: b allows you to perform a "whole words only" search using a regular expression in the form of bwordb. A "word character" is a character that can be used to form words. All characters that are not "word characters" are "non-word characters".

In all flavors, the characters [a-zA-Z0-9_] are word characters. These are also matched by the short-hand character class w. Flavors showing "ascii" for word boundaries in the flavor comparison recognize only these as word characters.

w stands for "word character", usually [A-Za-z0-9_]. Notice the inclusion of the underscore and digits.

B is the negated version of b. B matches at every position where b does not. Effectively, B matches at any position between two word characters as well as at any position between two non-word characters.

W is short for [^w], the negated version of w.

Monday, December 26, 2022

If you don't want to use javascript, you can handle it via php. Take a look at this lib: And then you could do something like:

include 'Mobile_Detect.php';
$detect = new Mobile_Detect();

if ($detect->isMobile()) {
    header('Location: yourpage.php');
Friday, October 21, 2022

Cookies are not the way to transfer variables between client and server. you should append key/variables pairs to your request URL using either a get (querystring) or post method.

jQuery ajax example;

$.get('' + NewCookieValue);
Monday, October 31, 2022

Try using about:blank as the URL. This should display a blank page in all browsers.

Monday, September 26, 2022
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :