ad

Monday, March 4, 2024

PHP comparison operators


PHP comparison operators

PHP Comparison operator

 

Comparison Operators:

  • Equal (==)
  • Identical (===)
  • Not equal (!= or <>)
  • Not identical (!==)
  • Greater than (>)
  • Less than (<)
  • Greater than or equal to (>=)
  • Less than or equal to (<=)

php comparison operators 

Example :-

<?php
$a=10;
$b=5;
$c=20;
$d=20;
var_dump($a < $c); //true
echo"<br>";
var_dump($a < $b);
echo"<br>";
var_dump($a<=$c);//t
echo"<br>";
var_dump($b>$c);//f
echo "<br>";
var_dump($c>=$d);//true
echo "<br>";
var_dump($c==$d);//t
echo"<br>";
var_dump($a != $d);//t
?>


php comparison operators 

OUTPUT :-

bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(true)
bool(true)


Related Post :-

about us page design template

php program to print alphabet pattern J

css box padding property

PHP operators

PHP operators

PHP operators


PHP operators 

  1. 1] Arithmetic Operators:

    • Addition (+)
    • Subtraction (-)
    • Multiplication (*)
    • Division (/)
    • Modulus (%)
    • Exponentiation (**)
  2. 2] Assignment Operators:

    • Assignment (=)
    • Addition assignment (+=)
    • Subtraction assignment (-=)
    • Multiplication assignment (*=)
    • Division assignment (/=)
    • Modulus assignment (%=)
  3. 3] Comparison Operators:

    • Equal (==)
    • Identical (===)
    • Not equal (!= or <>)
    • Not identical (!==)
    • Greater than (>)
    • Less than (<)
    • Greater than or equal to (>=)
    • Less than or equal to (<=)
  4. 4] Logical Operators:

    • AND (&& or and)
    • OR (|| or or)
    • NOT (! or not)
    • XOR (exclusive OR) (xor)
  5. 5] Increment/Decrement Operators:

    • Increment (++)
    • Decrement (--)
  6. 6] String Operators:

    • Concatenation (.)
    • Concatenation assignment (.=)
  7. 7] Array Operators:

    • Union (+)
    • Equality (==)
    • Identity (===)
    • Inequality (!= or <>)
    • Not identical (!==)
  8. 8] Ternary Operator:

    • Syntax :-
  9. (condition) ? expression1 : expression2;

it works:

  • 1] If the condition evaluates to true, the expression1 is executed.
  • 2] If the condition evaluates to false, the expression2 is executed.
Related Post :-

php program to print alphabet pattern F

php if statements

create menu card in html code table format

PHP data Type

 Variable Data Type in PHP

PHP data type


1] PHP String :-

        Represents a sequence of characters.

Example: $name = "seeta";

2] PHP Integer :-

Represents whole numbers without decimal points.

Example :- $number = 100;

3] PHP Float :-

Floating point numbers or Doubles

Represents numbers with decimal points.

Example :- $float_number = 9.7;

4] PHP Boolean :-

Represents true or false values.

Example: true;

5] PHP Array :-

Represents a collection of elements, each identified by a key.

Example: $colors = array("red", "green", "blue");

6] PHP Object :-

Represents instances of user-defined classes.

Example:

class Car { public $color = "blue"; public $make = "Toyota"; } $car = new Car();

7] PHP NULL :-
Represents a variable with no value.
Example: $variable = null;
  1. 8] PHP Resource :-
  2. Represents a special variable that holds a reference to an external resource.
  3.    A common example of using the resource data type is a database call.                         It is the storing of a reference to functions and resources external to PHP.

  4. Variable data type
    Example

    /* data type  variable */
    <?php
    $no1=10;
    $no2=85.99;
    $name1='aman';
    $name2="aishwarya";
    $status="false";
    $student=array("payal","aishwary");

    VAR_DUMP($no1);
    var_dump($no2);
    var_dump($name1);
    var_dump($name2);
    var_dump($status);
    var_dump($student);
    ?>


    variable data type
    Output

    variable data type/output


    Related Post :-

php program to print alphabet pattern A

Advantage and disadvantage of javascript

forgot password form