Comparison

The operators for comparison in PHP are the following:

Operator Name Returns true, if...
== equal left & right side equals
=== identical == is true, and both sides have the same type
!= not equal left & right are not equal after type juggling
<> not equal synonym of !=
!== not identical != is true, or their types differ
<> not equal synonym of !=
< less than left side is strictly less than right side
> greater than left side is strictly greater than right side
<= less than or equal to left side is less than or equal to right side
>= greater than or equal to left side is greater than or equal to right side
<=> spaceship integer less than, equal to, or greater than zero when left side is respectively less than, equal to, or greater than right side (>= PHP 7).
$a  $b
 $c
null coalescing first operand from left to right that exists and is not NULL. NULL, if no values are defined and that not NULL (>= PHP 7).

Example of comparisons

This example sets and prints arrays.

Crystal Clear app terminal.png PHP Code:

<?php
$value1 = 5;
$value2 = 7;

if ($value1 == $value2) {
  print('value1 is equal to value2');
} else {
  print('value1 is unequal to value2');
}
?>

Crystal Clear app kscreensaver.png PHP Output:

value1 is unequal to value2

Crystal 128 yast default.png HTML Render:

value1 is unequal to value2


External Links



  This article uses material from the Wikipedia page available here. It is released under the Creative Commons Attribution-Share-Alike License 3.0.

PHP_Programming/Comparison
 



 

Connect with defaultLogic
What We've Done
Led Digital Marketing Efforts of Top 500 e-Retailers.
Worked with Top Brands at Leading Agencies.
Successfully Managed Over $50 million in Digital Ad Spend.
Developed Strategies and Processes that Enabled Brands to Grow During an Economic Downturn.
Taught Advanced Internet Marketing Strategies at the graduate level.


Manage research, learning and skills at defaultLogic. Create an account using LinkedIn or facebook to manage and organize your Digital Marketing and Technology knowledge. defaultLogic works like a shopping cart for information -- helping you to save, discuss and share.

Visit defaultLogic's partner sites below:
PopFlock.com : Music Genres | Musicians | Musical Instruments | Music Industry
NCR Works : Retail Banking | Restaurant Industry | Retail Industry | Hospitality Industry

  Contact Us