PHP Operators and type of php operators

PHP Operators

Operators in PHP
What is an operator in PHP?
Operators in PHP languages is used to perform specific tasks. Tells the processor of PHP to do a specific tasks. (+) this symbols tells to add values.

Type of Operators

  1. Arithmetic Operators in PHP
  2. Assignment Operators in PHP
  3. Logical Operators in PHP
  4. Increment / Decrement Operator in PHP
  5. String Operators in PHP
  6. Comparison Operators in PHP

Arithmetic Operators in PHP

The term arithmetic is commonly known as the branch of mathematics which mostly used for the classical operations. In PHP arithmetic operation are of several types:

  1. Addition Operation in PHP
  2. Subtraction Operation in PHP
  3. Identity Operation in PHP
  4. Negation Operation in PHP
  5. Multiplication Operation in PHP
  6. Division Operation in PHP
  7. Modulus Operation in PHP
  8. Exponential Operation in PHP

Example of Athematic Operation of PHP

 
//Addition Operation in PHP Code Example
$a=10;
$b=5;
//adding value of $a+$b and echo to display.
echo $a+$b . “
“;
//Subtraction Operation in PHP Code Example
$x=20;
$y=5;
//subtracting the value $x-$y; and display output by echo .
echo $x-$y . “
“;
//Identity Operations in PHP Code Example
+$i=220;
//var_dump() function is used to display types of variable
var_dump($i);
//Negation Operation in PHP Code Example
$n=11;
//-$n is opposite to $n.
echo -$n . “
“;
//Multiplication Operation in PHP Code Example
$z=5;
$h=5;
//$z*$h is multiplying two values
echo $z * $h . “
“;
//Division Operation in PHP Code Example
$p=10;
$q=2;
//$p/$q ‘/ ’ is used to divide $p over $q quotient and display output by echo
echo $p / $q . “
“;
//Modulus Operation in PHP Code Example
$q=50;
$w=5;
// $q % $w ‘%’ sign is used to find modulus $q over $w (reminder).
echo $q % $w .”
“;
//Exponential Operation in PHP Code Example
$s=3;
$d=5;
//$s is the power of $yth
//$s ** $d;
?>

Output of Arithmetic Operators in PHP Code Example

Arithmetic Operator in PHP

Assignment Operator in PHP

An assignment operator in PHP is used to assign a value to a variable. For assigning a value in php ‘=’ sign is used variable name comes before equal and values that’s going to assign comes after the equal sign.

‘Variablename = Value’

Code example of Assignment Operator in PHP

” . $b;
?>

Output of Assignment Operator in php

10

Hello WorldViewIT

Comparison Operator in PHP

Comparison Operators in php are of different types main purpose of these type of operators is to check the values or simply compare two values. So, the values are of two types (numeric, String).

Code Example of Comparison Operator in php

 

Output of Comparison Operators in PHP

Increment / Decrement Operators in PHP

In php increment operator is use for the increment (increase in value) in the values of variable.

So for decrement operator in php works vice versa of increment operator. It is use to decrease the value of variable.

Both increment and decrement operators have four types:

  1. Post Increment
  2. Post Decrement
  3. Pre Increment
  4. Pre Decrement

Post-increment operator in php is use to make increment after returning value of variable $w $w++.

Post-decrement operator in php is use to make decrease value after returning a value of variable $w $w–.

Pre-increment operator in php is use to make increment before returning a value of variable $w  ++$w.

Pre-decrement operator in php is use to make decrement before returning a value of variable $w          –$w.

Code Example of Increment / Decrement Operator in PHP

“;
// pre-increment in php code example
$w=10;
echo ++$w .”
“;
// decrement operator in php code example
// post decrement in php code example
$w=10;
echo $w–.”
“;
//pre decrement in php code example
$w=10;
echo –$w;
?>

Output of Increment Decrement Operator in PHP

String Operator in PHP

String in php is a datatype click here to learn about strings in php. String operators in php is use to concatenate / combine to two string and also use to append two strings in php.

Code example of String Operator in PHP

 

Output of String Operators

String Operator in PHP

Logical Operators in PHP

In php logical Operators are used to compare conditional statements as far as it is use in programs to make decisions.

Basic Logical Operators in php are followed below:

  1. And && (If two variables are True than True)
  2. OR || (If both of two variables anyone is true than True)
  3. Not !  (True if one is not true)

Code Example of Logical Operators in PHP

{
echo “Hello WorldViewIT
“;
}
// And Operator using && symbols to decide is it true
if($a==10 && $b==20)
{
echo “Hello WorldViewIT
“;
}
// OR operator in php code example
if($a == 10 or $b == 10)
{
echo “Hello WorldViewIT OR Operator
“;
}
// OR operator using symbols in PHP
if($a == 10 || $b == 10)
{
echo “Hello WorldViewIT OR Operator
“;
}
// Not Operator in PHP Code Example
if($a !== 20)
{
echo “Hello WorldViewIT Not Operator”;
}
?>

Output of logical Operator in PHP

3,145 Comments on “PHP Operators and type of php operators

  1. darknet market links [url=https://asapmarketlinks.com/ ]deep web drug markets [/url] [url=https://asapmarketurls.com/ ]dark market onion [/url]

  2. dark web market links [url=https://asapmarketlinks.com/ ]darknet market list [/url] [url=https://asapmarketlinks.com/ ]dark market url [/url]