Comparison operators in PHP
By: Andi, Stig and Derick
Comparison operators enable you to determine the relationship between two operands.
When both operands are strings, the comparison is performed lexicographically. The comparison results in a Boolean value. For the following comparison operators, automatic type conversions are performed, if necessary.
Operator | Name | Value |
= = | Equal to |
Checks for equality between two arguments performing type
conversion when necessary: |
!= | Not equal to | Inverse of = =. |
> | Greater than |
Checks if first operand is greater than second |
< | Smaller than |
Checks if first operand is smaller than second |
>= | Greater than or equal to |
Checks if first operand is greater or equal to second |
<= | Smaller than or equal to |
Checks if first operand is smaller or equal to second |
For the following two operators, automatic type conversions are not performed and, therefore, both the types and the values are compared.
Operator | Name | Value |
= = = | Identical to |
Same as == but the types of the operands have to match. No
automatic type conversions are performed: |
!= = | Not identical to | The inverse of = = =. |
Comment on this tutorial
- Data Science
- Android
- AJAX
- ASP.net
- C
- C++
- C#
- Cocoa
- Cloud Computing
- HTML5
- Java
- Javascript
- JSF
- JSP
- J2ME
- Java Beans
- EJB
- JDBC
- Linux
- Mac OS X
- iPhone
- MySQL
- Office 365
- Perl
- PHP
- Python
- Ruby
- VB.net
- Hibernate
- Struts
- SAP
- Trends
- Tech Reviews
- WebServices
- XML
- Certification
- Interview
categories
Subscribe to Tutorials
Related Tutorials
PHP code to write to a CSV file for Microsoft Applications
PHP code to write to a CSV file from MySQL query
PHP code to import from CSV file to MySQL
Password must include both numeric and alphabetic characters - Magento
Error: Length parameter must be greater than 0
PHP file upload prompts authentication for anonymous users
PHP file upload with IIS on windows XP/2000 etc
Multiple File Upload in PHP using IFRAME
Resume or Pause File Uploads in PHP
Exception in module wampmanager.exe at 000F15A0 in Windows 8