
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
1. Arithmetic Operator
Important Same Other Languages Operator
Arithmetic operator in PHP Language
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)
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
<?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 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)
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 Operator2.|| 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.
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)
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)
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:4 Decrement --y:4
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.
How To Use Integer Data Types in PHP?
<?php $x=50; echo "$x is integer<br>"; echo var_dump($x); ?>*****OUTPUT*****50 is integerint 50
Float Data_Type in PHP Language
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
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
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
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
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
How To Use NULL Data Types in PHP?
<?php $x=NULL; echo var_dump($x); ?>*****OUTPUT*****NULL
Comments in PHP Language
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
The text between /* and */ is not executed by the compiler.
0 Comments