Common Operators

List of Operators

  • Math ops: + - * / %
  • Logical: || && ! and or xor
  • Bitwise: & | ^ ~ << >>
  • String: =
  • Assignment: = += -= *= /= |= ^= etc.
  • Increment/Decrement: ++ --
  • Comparison: == === != <> !== < > <= >= ?:

Some Examples

<?php
    $a = 254 + 1;
    echo $a   . "<br />";    
    echo --$a . "<br />";
    echo ($a & 1) . "<br />";
    echo ($a & 127) . "<br />";
    echo ($a >> 1) . "<br />";
?>

Example 2

<?php

$a = 2;

if($a == 2) {
    echo 'True 1';
} else {
    echo 'False 1';
}


if($a == '2') {
    echo 'True 2';
} else {
    echo 'False 2';
}


if($a === '2') {
    echo 'True 3';
} else {
    echo 'False 3';
}


if($a != 2) {
    echo 'True 4';
} else {
    echo 'False 4';
}


if($a !== '2') {
    echo 'True 5';
} else {
    echo 'False 5';
}


if($a == 2  &&  $a !== '2') {
    echo 'True 6';
} else {
    echo 'False 6';
}



$a == 2 ? 'True 7'  : 'False 7';

$a === '2' ? 'True 8' : 'False 8';

?>

Loading ...

Related Results :

  1. Basic String Operations
  2. Common Operators
Note :
  • Related Posts are generally User Blog posts.
  • or Other tutorials from other networks of w3clan.com.
  • Any registered user can create related posts based on search term tags.

About the Author