Best Php Operator List in the World
How does run PHP script PHP operators?

    Best Php Operator List in the World

    Operators PHP Language: A Php Language is a Special operator that is a mathematical operation performed in the Php language. Operator Can be used to solve the mathematical operation Perform logically. Operators have used variables and data calculation.

    Types of Operator in PHP

    1. Arithmetic Operator


    2. Relational Operator

    3. Logical Operator 

    4. Assignment Operator

    5. Bitwise Operator

    6. Increment Operator

    7. Decrement Operator

    8. Conditional Operator


    Important Same Other Languages Operator 

    👉C++ Operators 

    👉Java Operators 

    👉 Python Operators


    Arithmetic operator in PHP Language

    Arithmetic Operator: A arithmetic operation is a used mathematical operation performed. It is many operations performed like additionsubtraction, multiplication, and division.

    Example of Arithmetic operator

    Addition:a+b or 10+10=20
    Here a is operands value (+) Addition is operator and b is operands. It can be used for additional operations performed.

    Subtraction:a-b or 20-10=10
    Here a is operands value (-) Subtraction sign is operator and b is operands. It can be used as Subtraction operations performed.

    Multiplication: a*b or 10*10=100
    Here a is operands value (*) Multiplication sign is operator and b is operands. It can be used Multiplication operations performed.

    Division:a/b or 10/5=2
    Here a is operands value (/) Division sign operator and b is operands. It can be used for Division operations performed.

    Modulas:a%b or 10%3=1
    Here a is operands value (%) Modules sign operator and b is operands. It can be used Modules operations performed.

    Arithmetic Operator  Table

    Sign.           Operation.         Example


    (+)              Addition                    (a+b)


    (-)               Subtraction              (a-b)  

     
    (*)              Multiplication         (a*b)


    (/)               Division                     (a/b)


    (%)            Modules                    (a%b)


    How To Use Arithmetic Operator in PHP?

    <?php 

    $x=13; 

    $y=5; 

    echo "Addition:".($x+$y)."<br>"; 

    echo "Subtraction:".($x-$y)."<br>"; 

    echo "Multiplication:".($x*$y)."<br>"; 

    echo "Division:".($x/$y)."<br>"; 

    echo "Modulas:".($x%$y)."<br>";


    *****OUTPUT*****

    Addition:18 

    Subtraction:8 

    Multiplication:65 

    Division:2.6 

    Modulas:3 


    Relational Operator in PHP Language

    Relational Operator: Relational operators are used in the comparison of the two operands. It can be using equal operands and condition check in this operator. Relational operator very most and useful operator.

    Relational Operator  Table

    Sign.      Operation.         Example


    (==)           Equal To              (a+b)


    (!=)           Not 
    Equal To       (a-b)   


    (>)            Greater Than       (a*b)


    (<)             Less Than           (a/b)


    (>=)   Grater than Or Equal  (a%b)


    (<=)   Less Than Or  Equal    (a%b)


    Logical Operator in PHP Language

    Logical Operators: PHP Language provides three logical operators. logical Operator tests more than one condition to make decisions.

    Types of Logical Operator

    1.&& AND Operator 
    2.|| OR Operator 
    3.!  NOT Operator 

    1. AND Operator can be used decisions are two values.AND Operator two values are True AND Operator return True. But two values are anyone False AND Operator return False.

    2. OR operator performs a logical condition on two expressions. if or Operator can be two expressions are True OR Operator return true. But any of the expressions are False OR Operator return True.

    3NOT operator is very easy Operator. it can be used condition are True NOT Operator returns False and condition are False NOT Operator returns True.

    How To Use Logical AND Operator in PHP?

    <?PHP
     
    $marks=55; 

    if($marks>=60) 
     echo "First division<br>"; 
    if($marks<60 && $marks>=45) 
    echo "Second division<br>"; 
    if($marks<45 && $marks>=33) 


    echo "Third division<br>"; 
    if($marks<33) 
    echo "Sorry!! You are Fail!!<br>"; 
    ?>
    *****OUTPUT*****
    Second division


    Assignment Operator  Table

    Sign.        Operation        Example


    (=)            a=b                         (a=b)


    (+=)        a+=b                      (a=a+b)   


    (-=)         a-=b                       (a=a-b)


    (*=)        a*=b                      (a=a*b)


    (/=)         a/=b                      (a=a/b)


    (%=)          a%=b               (a=a%b)


    Bitwise Operator in PHP Language

    Bitwise Operator: A Bitwise operator is an operation performed on the data bit level.

    the bitwise operator is also shift bit right to left.
    Note:Bitwise operators are not allowed to float and double.

    Bitwise Operator  Table

    Sign.        Operation.         Example


    (&)           Bitwise AND         (a&b)


    (|)             Bitwise OR             (a|b)  

     
    (<<)         Bitwise LEFT        (a<<2)


    (>>)        Bitwise RIGHT      (a>>2)


    How To Use Bitwise Operator in PHP?

    <?php 
    $x=3; 
    $y=5; 
    echo "x&y:".($x&$y)."<br>"; 
    echo "x|y:".($x|$y)."<br>"; 
    echo "x>>1:".($x>>1)."<br>"; 
    echo "x<<2:".($x<<2)."<br>"; 
    echo "x^y:".($x^$y)."<br>";
     ?> 
    *****OUTPUT*****
    x&y=1 
    x|y=7 
    x>>1=1 
    x<<2=12 
    x^y=6 


    Increment Operator in PHP Language

    Increment Operator:Increment Operators are useful operators generally used.like++x and x++ means x=x+1.

    pre-increment first add one to the operand and then the result is assigned to the variable on the left.

    post-increment first assigns the value to the variable on the left and then increments the operand.

    Decrement Operator: A Decrement Operator has used the decrease the value. like --x and x--.

    Pre-decrement first less one to the operands and then the result is assigned to the variable on the left.

    Post-decrement first assigns the value to the variables on the left and then decrements the operands.

    How To Use Increment/Decrement Operator in PHP?

    <?PHP 
    $x=3; 
    $y=5; 
    echo "Increment ++x:".++$x."<br>"; 
    echo "Decrement --y:".--$y."<br>"; 
    ?>
    *****OUTPUT*****
    Increment ++x:
    Decrement --y:



    Conditional  Operator in PHP Language

    Conditional Operators: If the condition is true second part will execute otherwise third part will execute.

    How To Use Conditional Operator in PHP?

    <?php 
    $x=3; 
    $y=5; 
    $str=$x>$y?"x is greater":"y is greater"; 
    echo $str; 
    ?
    *****OUTPUT*****
    y is greater


    Data Types PHP: It is a type of data that is used in the program. 
    PHP supports different types of data types. Now I am going to explain one by one.

    Integer in PHP: A number without decimal is called an integer value. It must have at least one digit. It may negative or positive. It must not have a decimal point.
    Range of integer value in PHP is between -2,147,483,648 and 2,147,483,647.
    var_dump() is a function that returns data type and its value.

    How To Use Integer Data Types in PHP?

    <?php $x=50; 
    echo "$x is integer<br>"; 
    echo var_dump($x);
     ?>
    *****OUTPUT*****
    50 is integer
    int 50


    Float Data_Type in PHP Language

    Float in PHP: A number with decimal is called float value. It must have at least one digit. It may be negative or positive. It must have a decimal point.

    How To Use Float Data Types in PHP?

    <?php 
    $x=25.8; 
    echo "$x is float value<br>"; 
    echo var_dump($x); 
    ?>

    *****OUTPUT*****
    25.8 is float value
     float 25.8 


    String Data_Types in PHP Language

    String in PHP: The sequence of characters is called string. It can be written in single or double-quotes.

    How To Use String Data Types in PHP?

    <?php $s1="This is string in double quote"; 
    $s2='This is string in single quote'; 
    echo $s1."<br>"; 
    echo $s2."<br>"; 
    echo var_dump($s1); 
    ?>
    *****OUTPUT*****
    This is the string in double quote 
    This is the string in a single quote 
    string 'This is the string in double quote' (length=30)


    Boolean Data_Types in PHP Language


    Boolean in PHP: It has two possible values True or False.

    How To Use Boolean Data Types in PHP?

    <?php 
    $s1=true; 
    $s2=false; 
    echo var_dump($s1)."<br>"; 
    echo var_dump($s2); 
    ?>
    *****OUTPUT*****
    boolean true 
    boolean false



    Object Data_Types in PHP Language

    Object: Object in PHP is used to store data. It is declared explicitly. Class is a necessary part to use an object because the object is the instance of a class.


    How To Use Object Data Types in PHP?

    <?php 
    class Program 
    function add() 
    {
    $x=50; 
    $y=50; 
    echo "This is a add method.<br>"; 
    echo "Sum=".($x+$y); 
    }
    $obj= new Program(); 
    obj->add();
    var_dump($obj); 
    ?>
    *****OUTPUT*****
    This is an additional method. 
    Sum:100


    Array Data_Types in PHP Language

    Array in PHP: Array is used to store multiple data in a single variable. array() function is used to create array.

    How To Use Array Data Types in PHP?

    <?php 
    $name=array("Kartik","Icoderweb","Programming"); 
    echo var_dump($name); 
    ?>
    *****OUTPUT*****
    array (size=3) 
    0 => string 'Kartik' (length=6) 
    1 => string 'Icoderweb' (length=9) 
    2 => string 'Programming' (length=11)  



    NULL Data_Types in PHP Language

    NULL Data Type in PHP: It has only one value NULL. NULL value to a variable means there is no value assigned to it. It represents a variable with no value.


    How To Use NULL Data Types in PHP?

    <?php 
    $x=NULL; 
    echo var_dump($x); 
    ?>
    *****OUTPUT*****
    NULL 



    Comments in PHP Language

    Comments in PHP: It is used to explain the code to make it more readable. It is not considered as a part of the program, in another word we can say that the compiler ignores the comment.
    PHP comments are statements that are not executed by the compiler.


    Types of comments in PHP

    1. Single line comment

    2. Multiline comment


    Single line comment: It is used to comment only one line. Two forward slashes(//) are used for single-line comments. Hash Symbol(#)is also used for commenting on a single line.


    How To Use Single Line Comment in PHP?

    <?php 
    //this is a single line comment 
    # this is also a single line comment 
    echo "Hello Friends"; 
    ?>



    Multi-Line Comments in PHP Language

    Multiline comment: A multiline comment is used to comment on a block of code. The multiline comment starts with /* and ends with */.
    The text between /* and */ is not executed by the compiler.


    How To Use Multiline Line Comment in PHP?

    <?PHP 
    /* This is a multiline comment 
    Write a program to find 
    the sum of two number 
    */ 
    ?>
    $x=50; 
    $y=20; 
    $z=$x+$y; 
    echo "Sum=".$z;