Monthly Archives: March 2011

Difference between ‘==’ (equal) and ‘===’ (identical) comparison operators in PHP

Two of the many comparison operators used by PHP are ‘==’ (i.e. equal) and ‘===’ (i.e. identical). The difference between the two is that ‘==’ should be used to check if the values of the two operands are equal or not. On the other hand, ‘===’ checks the values as well as the type of operands.

Let me explain more using some examples:
‘==’ (Equal):

 if("10" == 10) echo "YES";
 else           echo "NO";</strong>

The code above will print “YES”. The reason is that the values of the operands are equal. Whereas when we run the example code below:
‘===’ (Identical):

 if("10" === 10) echo "YES";
 else            echo "NO";

The result we get is “NO”. The reason is that although values of both operands are same their types are different, “22” (with quotes) is a string while 22 (w/o quotes) is an integer. But if we change the code above to the following:

 if("22" === (string)22) echo "YES";
 else           echo "NO";

Then, the result will be “YES”. Notice that we changed the type of right operand to a string which is the same as the left operand (i.e. string). Now, the types and values of both left and right operands are the same hence both operands are identical.

Difference between FLOAT, DOUBLE and REAL.

FLOATs store floating point numbers with 8 place accuracy and take up 4 bytes. DOUBLEs store floating point numbers with 16 place accuracy and take up 8 bytes. REAL is a synonym of FLOAT for now.

Difference between URL and URI

“…a URL is a type of URI that identifies a resource via a representation of its primary access mechanism (e.g., its network “location”), rather than by some other attributes it may have. Thus as we noted, “http:” is a URI scheme. An http URI is a URL. The phrase “URL scheme” is now used infrequently, usually to refer to some subclass of URI schemes…”
URI stands for Universal Resource Identifier and URL stands for Universal Resource Locator. Often times people use the terms interchangably, which is not entirely correct. A URL is a subset of the URI popular protocols. These are protocols (http://, ftp://, mailto:). Therefore all URLs are URIs. The term URL is deprecated and the more correct term URI is used in technical documentation. All URIs are means to access a resource on the Internet and are a a technical short hand used to link to the resource. URIs always designate a method to access the resource and designate the specific resource to be accessed.” >

A URI is an identifier for some resource, but a URL gives you specific information as to obtain that resource. A URI is a URL and as one commenter pointed out, it is now considered incorrect to use URL when describing applications. Generally, if the URL describes both the location and name of a resource, the term to use is URI. Since this is generally the case most of us encounter everyday, URI is the correct term.

Diffrence between mysql and mysqli

There is no big difference between Mysql and Mysqli. Mysqli is nothing but an improved extension of Mysql which supports OOP. mysqli extension allows you to access the functionality provided by MySQL 4.1 and above. In some blogs and benchmark says that Mysql is slightly faster than the Mysqli Extension.

MySQL is an RDBMS that runs as a server and provides multi-user access to multiple databases; MySQLi is an extension of MySQL.

2. MySQL does not need GUI tools in order to administer databases or manage the data therein; MySQLi builds upon the features of MySQL and include object oriented interface, support for previously prepared statements, and enhanced embedded server support.