We won't Spam You

Sajjad Hossain, 0, * *

There is an operator in any programming language. It is very important to learn these operators which are used continuously. You should learn them if you sit for Marketplace like Upwork, Elance or Zend etc. There are many questions in the examination the topic of the operator which is not usually used. Anyway we are showing you all.

Operator: For example $x + $y; Here $x + $y these are Operand and plus (+) stain is operator. There are many kinds of operators such as +, -, *, /, !, ++, --, ||, and etc. Many operators just worked with an operand like ++(increment operator) or ! (not operator) etc. This is called Unary operator.

There are many operators which are worked in two operand like +(Addition or Plus operator) or –( Subtraction or minus operator) etc. Understandingly these operators are Binary operator. Bulk operators are Binary operator.

There are many operators which are worked in three operand like ? : . Understandingly these operators are Tenary operator. There is only one Tenary operator.

There are some kinds of operator, such as---

Arithmetic operator:

Do you remember the mathematics of pimping time? To do the mathematics you must used the stain like Addition or Plus (+),Subtraction (-),Multiplication(x), Division . Now there use are same here----

Before solve the modulus make two operands as integer (if decimal tends). Then it solve modulus. And divisible mark is the result mark. Such as-----

If it is $x = -20 and $y = 5 so that the result of ($x%$y) is -5.

**The operation come first because of the first bracket and then the concat come with sting. The result is fault if the bracket is ejected.

** The meaning of $x = 20 that means 20. So, if it is $y = ($x = 20) + 5; than the result of $y or output operator is 25 because it becomes $y = 20+5 now.

Assignment operator:

Assignment operator is normally equal stain. With this operator there are some assignment operator which is called Combined Operator. There are some example are given bellow:

$x = 20 means that the value of $x impute 20. Or you would say that it is impute from right expation to left operand.

Now there is given $x += 20; In output the of $x += 20 is 40 and accorded to $y = ' PHP Tutorials'; in output we are seeing that it comes PHPAns Basic Tutorials. Here the operator of += and .= is given than the main variable encroached the next one. In technical language it is called assignment by value.

Assignment by reference:

The using of PHP and stain the same value of two variables alters in assign.

Because of assignment by value the value of main variable is copy to next variable. If you do it by assignment by reference it is not the previous one. Now if we change the value of $x then the value of $y is changed such as

See, the $y is changed cause $y is referance to $x.

In next article we will learn about,

**Categories:** Tutorials, Basic PHP, PHP Operators, What is PHP Operator, How to write PHP Operator, PHP Operator Tutorial

Operator: For example $x + $y; Here $x + $y these are Operand and plus (+) stain is operator. There are many kinds of operators such as +, -, *, /, !, ++, --, ||, and etc. Many operators just worked with an operand like ++(increment operator) or ! (not operator) etc. This is called Unary operator.

There are many operators which are worked in two operand like +(Addition or Plus operator) or –( Subtraction or minus operator) etc. Understandingly these operators are Binary operator. Bulk operators are Binary operator.

There are many operators which are worked in three operand like ? : . Understandingly these operators are Tenary operator. There is only one Tenary operator.

There are some kinds of operator, such as---

Arithmetic operator:

Do you remember the mathematics of pimping time? To do the mathematics you must used the stain like Addition or Plus (+),Subtraction (-),Multiplication(x), Division . Now there use are same here----

Example | Name of operator | Explain |

-$x | Negation | The opposite of $x |

$x + $y | Addition | Addition between $x and $y |

$x - $y | Subtraction | Subtraction between $x to $y |

$x * $y | Multiplication | Multiplication between $x and $y |

$x / $y | Division | Division between $x and $y |

$x % $y | Modulus | Residue after Division between $x and $y |

$x ** $y | Exponentiation | It is not use extensively in the version of PHP 5.6 |

`<?php`

$x = 20;$y = 5;

echo 'Negation of $x : '. (-$x).'<br/>';

echo 'Addition of $x and $y : '. ($x + $y).'<br/>';

echo 'Subtraction of $y from $x : '. ($x - $y).'<br/>';

echo 'Multiplication of $x and $y : '. ($x * $y).'<br/>';

echo 'Division of $x by $y : '. ($x/$y).'<br/>';

echo 'Remainder of $x divided by $y : '. ($x % $y);

?>

Output:

Negation of $x : -20

Addition of $x and $y : 25

Subtraction of $y from $x : 15

Multiplication of $x and $y : 100

Division of $x by $y : 4

Remainder of $x divided by $y : 0

Before solve the modulus make two operands as integer (if decimal tends). Then it solve modulus. And divisible mark is the result mark. Such as-----

If it is $x = -20 and $y = 5 so that the result of ($x%$y) is -5.

**The operation come first because of the first bracket and then the concat come with sting. The result is fault if the bracket is ejected.

** The meaning of $x = 20 that means 20. So, if it is $y = ($x = 20) + 5; than the result of $y or output operator is 25 because it becomes $y = 20+5 now.

Assignment operator:

Assignment operator is normally equal stain. With this operator there are some assignment operator which is called Combined Operator. There are some example are given bellow:

`<?php`

// 20 assigned to $x (assignment operator)

$x = 20;

// combined operator +=

$x += 20; /* this means $x = $x + 20*/

echo $x .'<br/>';

//combined operator .=

$y = 'PHPAns Basic';

$y .= ' PHP Tutorials'; /* this means $y = $y . ' Tutorials'*/

echo $y;

?>

Output

40

PHPAns Basic PHP Tutorials

$x = 20 means that the value of $x impute 20. Or you would say that it is impute from right expation to left operand.

Now there is given $x += 20; In output the of $x += 20 is 40 and accorded to $y = ' PHP Tutorials'; in output we are seeing that it comes PHPAns Basic Tutorials. Here the operator of += and .= is given than the main variable encroached the next one. In technical language it is called assignment by value.

Assignment by reference:

The using of PHP and stain the same value of two variables alters in assign.

`<?php`

// assignment by reference

$x = 20;

$y = &$x;

echo $x.'<br/>';

echo $y;

?>

Output

20

20

Because of assignment by value the value of main variable is copy to next variable. If you do it by assignment by reference it is not the previous one. Now if we change the value of $x then the value of $y is changed such as

`<?php`

// assignment by reference

$x = 20;

$y = &$x;

$x = 4;

echo $x.'<br/>';

echo $y;

?>

Output

4

4

See, the $y is changed cause $y is referance to $x.

In next article we will learn about,

**php bitwise operators****php logical operators****php operators precedence**

GET EMAIL UPDATES

Join with our 32000+ subscribers and get our latest articles in your email inbox for free.We always respect your privacy and take protecting it seriously. Recommended For You

- How To Get Alexa Site Rank History
- AJAX PHP Shopping Cart with jQuery
- Random code generator in PHP
- Ajax Login Form Using jQuery and PHP
- 15 useful htaccess tips and tricks
- 5 Tips To Increase Website Page Speed
- Create hex to rgba converter tool
- Get user real IP address in PHP
- Get location using IP address in PHP
- Image watermark in PHP

Create an free account and start learning & sharing! Sign Up