Asked  2 Years ago    Answers:  5   Viewed   62 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

No, it doesn't have one. For this reason most popular libraries come with one in their utility packages. Check out jQuery's inArray and Prototype's Array.indexOf for examples.

jQuery's implementation of it is as simple as you might expect:

function inArray(needle, haystack) {
    var length = haystack.length;
    for(var i = 0; i < length; i++) {
        if(haystack[i] == needle) return true;
    return false;

If you are dealing with a sane amount of array elements the above will do the trick nicely.

EDIT: Whoops. I didn't even notice you wanted to see if an array was inside another. According to the PHP documentation this is the expected behavior of PHP's in_array:

$a = array(array('p', 'h'), array('p', 'r'), 'o');

if (in_array(array('p', 'h'), $a)) {
    echo "'ph' was foundn";

if (in_array(array('f', 'i'), $a)) {
    echo "'fi' was foundn";

if (in_array('o', $a)) {
    echo "'o' was foundn";

// Output:
//  'ph' was found
//  'o' was found

The code posted by Chris and Alex does not follow this behavior. Alex's is the official version of Prototype's indexOf, and Chris's is more like PHP's array_intersect. This does what you want:

function arrayCompare(a1, a2) {
    if (a1.length != a2.length) return false;
    var length = a2.length;
    for (var i = 0; i < length; i++) {
        if (a1[i] !== a2[i]) return false;
    return true;

function inArray(needle, haystack) {
    var length = haystack.length;
    for(var i = 0; i < length; i++) {
        if(typeof haystack[i] == 'object') {
            if(arrayCompare(haystack[i], needle)) return true;
        } else {
            if(haystack[i] == needle) return true;
    return false;

And this my test of the above on it:

var a = [['p','h'],['p','r'],'o'];
if(inArray(['p','h'], a)) {
    alert('ph was found');
if(inArray(['f','i'], a)) {
    alert('fi was found');
if(inArray('o', a)) {
    alert('o was found');
// Results:
//   alerts 'ph' was found
//   alerts 'o' was found

Note that I intentionally did not extend the Array prototype as it is generally a bad idea to do so.

Thursday, November 24, 2022

I couldn't find any major points on JetBrains' website and even Google didn't help that much.

You should train your search-fu twice as harder.


NOTE: PhpStorm includes all the functionality of WebStorm (HTML/CSS Editor, JavaScript Editor) and adds full-fledged support for PHP and Databases/SQL.

Their forum also has quite few answers for such question.

Basically: PhpStorm = WebStorm + PHP + Database support

WebStorm comes with certain (mainly) JavaScript oriented plugins bundled by default while they need to be installed manually in PhpStorm (if necessary).

At the same time: plugins that require PHP support would not be able to install in WebStorm (for obvious reasons).

P.S. Since WebStorm has different release cycle than PhpStorm, it can have new JS/CSS/HTML oriented features faster than PhpStorm (it's all about platform builds used).

For example: latest stable PhpStorm is v7.1.4 while WebStorm is already on v8.x. But, PhpStorm v8 will be released in approximately 1 month (accordingly to their road map), which means that stable version of PhpStorm will include some of the features that will only be available in WebStorm v9 (quite few months from now, lets say 2-3-5) -- if using/comparing stable versions ONLY.

UPDATE (2016-12-13): Since 2016.1 version PhpStorm and WebStorm use the same version/build numbers .. so there is no longer difference between the same versions: functionality present in WebStorm 2016.3 is the same as in PhpStorm 2016.3 (if the same plugins are installed, of course).

Everything that I know atm. is that PHPStorm doesn't support JS part like Webstorm

That's not correct (your wording). Missing "extra" technology in PhpStorm (for example: node, angularjs) does not mean that basic JavaScript support has missing functionality. Any "extras" can be easily installed (or deactivated, if not required).

UPDATE (2016-12-13): Here is the list of plugins that are bundled with WebStorm 2016.3 but require manual installation in PhpStorm 2016.3 (if you need them, of course):

  • Cucumber.js
  • Dart
  • EditorConfig
  • EJS
  • Handelbars/Mustache
  • Java Server Pages (JSP) Integration
  • Karma
  • LiveEdit
  • Meteor
  • PhoneGap/Cordova Plugin
  • Polymer & Web Components
  • Pug (ex-Jade)
  • Spy-js
  • Stylus support
  • Yeoman
Tuesday, November 8, 2022

Note: I am assuming by 'PHP to PHP5' you mean from PHP4 to PHP5. PHP5 is not a different languages from PHP, it is simply a different version.

PHP4 to PHP5

Here is the main differences between PHP4 and PHP5.

The specific OOP changes are featured in the Object Model

One of the places that page points that will give you the basics to how OOP works in PHP would be the Classes and Object reference page:

PHP Class Examples

If you want some specific examples of how OOP is used in PHP, you might want to look at my answer on some basic classes you might use in a web development setting:


Learning PHP

To learn PHP, you can do a search on PHP and OOP on , and the first few results give you resources to do so:


If you want to skip clicking the link, you can just go to, cause I guarentee that almost all of them point there. PHP has one of the best documentations out there, and it is extremely easy to use, and you will return to it very, very often.

For the record, the first result talks about how to learn object-oriented programming in php.

Friday, September 16, 2022

You can switch the version here:

1. Press CTRL+ALT+S

2 Search for JavaScript & click the select field. and then select ECMAScript 6

Wednesday, August 3, 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 :

Browse Other Code Languages