phpeveryday.com

The best tutorial of php, php framework, php strategies, object oriented oriented,


PHP Operators: Relation Operators

Tag: operator, Relation Operators   Category: PHP Basic
post: 08 Mar 2008 read: 549


PHP Operators Step By Step Tutorial - Part 6: Relation operator or which also referred as comparison operator is the operator that is used to conduct a comparison between two value or expression in order to get the result of true and false.

Table Relationship Operator

Operator Info example
== Equal to $x = 3;
$y = 4;
$x == $y
// the result : false or 0
True if $x is equal to $y
!=
or
<>
Unegual $x = 3;
$y = 4;
$x == $y
// the result : true or 1
True if $x is unegual than $y
=== Identik $x = 2;
$y = 2;
$x === $y
//the result : true or 1
True if $x is equal to $y as well as owning is the same type
!== Not Identik $x = 2;
$y = 5;
$x !== $y
//the result : false or 0
True if $x is not equal to $y or also both do not have is the same type
> Bigger $x = 2;
$y = 5;
$ x >$y
//the result : false or 0
True if $x is bigger than $y
< Smaller $x = 2;
$y = 5;
$ x <$y
//the result : true or 1
True if $x is smaller than $y
>= Bigger or equal to $x = 2;
$y = 5;
$ x >=$y
//the result : false or 0
True if $x is bigger or equal to $y
<= Smaller or equal to $x = 2;
$y = 5;
$ x <=$y
//the result : true or 1
True if $x is smaller or equal to $y

Pay attention to the example of using relationship operator at script as following:

File name: relationoperator.php


<html>
<head>
<title>Using Relation Operator</title>
</head>

<body>
<h1>The example for using relation operator</h1>
<?
$s = 100;
$a = 50;
$y = "310 pack";
$i = "me";
$o = "you";
printf ("$s == $a :%d <br>", $s==$a);
printf ("$s != $a :%d <br>", $s!=$a);
printf ("$s <> $a :%d <br>", $s<>$a);
printf ("$s === $y :%d <br>", $s===$y);
printf ("$s !== $y :%d <br>", $s!==$y);
printf ("$s > $a :%d <br>", $s > $a);
printf ("$i > $o :%d <br>", $i > $o);
printf ("$s < $a :%d <br>", $s < $a);
printf ("$i < $o :%d <br>", $i < $o);
printf ("$s >= $a :%d <br>", $s >= $a);
printf ("$i >= $o :%d <br>", $i >= $o);
printf ("$s <= $a :%d <br>", $s <= $a);
printf ("$i <= $o :%d <br>", $i <= $o);
?>
</body>
</html>
php relation operator


Series this article:
PHP Operators: Introduction
PHP Operators: Arithmetic Operators
PHP Operators: Assignment Operators
PHP Operators: Assignment Operators Table
PHP Operators: Bitwise Operators
PHP Operators: Relation Operators
PHP Operators: Ternary Operator
PHP Operators: Error Control Operator
PHP Operators: Execution Operator
PHP Operators: Increment or Decrement Operator
php Operators: Logic Operator
PHP Operators: String Operator
PHP Operators: Array Operator
PHP Operators: Object Operator
PHP Operators: Operator Priority
PHP Constants: Introduction

| Give Your Opinion | Recommend
Share and Bookmark to: These icons link to social bookmarking sites where readers can share and discover new web pages.
digg del.icio.us technorati Ma.gnolia BlinkList

Recommended articles by other readers:
Web Services: How PHP Kiss VB.NET? (Part 1)
Chart: How to Build Cool Animation Real Time Chart
Joomla: Fast Road to Understand Component Programming
Email: Send Attachement Mail
mod_rewrite - Part 1: create your "fantasy" URL

What do You Think?
Your Name *:
Email *:
(Will not be published)
Website/URL:
Your Comment *:
* Required


615
posting