Difference Between


(1) echo and print

echo print
Echo statement is used to display one or more strings.
Print statement is used to display only one string.
It does not return any value. It always returns a true value.
It is faster as compared to print. It is slower as compared to echo.
Example:
echo "Hello","How","Are","You";
Example:
echo "Hello How Are You";

     

(2) Numeric Array and Associative Array

Numeric Array Associative Array
In numeric array each element having Numeric key associated with it. Key value always starts with 0.
In Associative array each element having key associated with it. The key can be either numeric or string.
Syntax:
$ArrayName = array (Value1,Value2,Value3);
Syntax:
$ArrayName = array (Key1=>Value1,Key2=>Value2,Key3=>Value3);
In order to create a numeric array there is no need to specify key for each element of an array explicitly.
In order to create an associative array key must be specified for each element of an array explicitly.
We can use while loop, for loop and do while loop along with numeric array.
We can not use while loop, for loop and do while loop along with associative array.

(3) GET and POST

GET POST
GET method transfer information from one page to another page through URL.
POST method transfer information from one page to another page through form collection.
GET method is insecure because information is visible in the URL. 
POST method is secure because information is not visible in the URL. 
In GET method we can transfer limited amount of information.
In POST method there is no restriction.
Information passed using GET method is stored in the browser history because it is transfered through URL.
Information passed using POST method is not stored in the browser history.
GET method should not be used while transfer sensitive information such as password.
POST method should be used while transfer sensitive information such as password.

(4) Session and Cookie

Session Cookie
Session is a temporary variable which is used to uniquely identify user on a website.
Cookie is a small piece of information which is used to store user specific information.
Session is created and stored on server side.
Cookie is created and stored on clienet side.
Session variable can be managed using $_SESSION super global variable.
Cookie can be managed using $_COOKIE super global variable.
In order to use Session variable we must have to start the session using session_start () function.
There is no need to start cookie in order to use it.
Session is destroyed when user logout from the website or close the browser.
Cookie is destroyed based on its expire time specified at the time of creating cookie.
Session can be destroyed using session_destroy () function.
Cookie can be destoyed using setcookie () function.

Widget is loading comments...

Download Projects


Download Programs