PHP Operators: Assignment Operators Table



PHP Operators Step By Step Tutorial - Part 4: Assignment operator Table:
Operator Info Example
= Placing right side to left side $r = 87
+= Enhancing right side to left side $r += 42
-= Tapering down right side to left side $r -= 10
*= Multiply right side to left side $r *= 2
/= Allot right side to left side $r /= 7
%= Putting down the result of modulus between left side variable value with right side value in left $r %= 1 or
$r : = $r % 2
&= Putting down the result of operation the "AND" operator to the left side variable value with right side value in left. $x &= $y or
$x :=$x & $y
|= Putting down the result of operation the "OR" operator to the left side variable value with right side value in left $x |= $y or
$x : = $x | $y
^= Putting down the result of operation the "XOR" operator to the left side variable value with right side value in left $x ^= $y or
$x : = $x ^ $y
.= Putting down the result of operation the "CONCAT" operator to the left side variable value with right side value in left >$x .= "more text" or
$x : = $x."more text"

Pay attention to the example of using assignment operator at script as following:

File name: assignmentoperator1.php

<html>
<head>
<title>Using Assignment Operator</title>
</head>

<body>
<h1>Operator Assignment</h1>
<?
	$x = 15;
	echo ("\$x = $x <br>");
	$x += 1 ;
	echo ("\$x += 1 = $x <br><br>");
	$x = 7;
	echo ("\$x = $x <br>");
	$x = $x + 2;
	echo ("\$x = \$x + 2 = $x <br><br>");
	$x = 87;
	echo ("\$x = $x <br>");
	$y = &$x;
	echo ("\$y = &\$x = $x <br><br>");
	$greeting = "good";
	echo ("\$greeting = $greeting <br><br>");
	$greeting .="night";
	echo ("\$greeting .= good = $greeting");
?>
</body>
</html>

The result of executing assignment operator.php:

assignment operator


Series this article:
PHP Operators: Introduction
PHP Operators: Arithmetic Operators
PHP Operators: Assignment Operators
PHP Operators: Assignment Operators Table
PHP Operators: Bitwise Operators
PHP Operators: Relation Operators
PHP Operators: Ternary Operator
PHP Operators: Error Control Operator
PHP Operators: Execution Operator
PHP Operators: Increment or Decrement Operator
php Operators: Logic Operator
PHP Operators: String Operator
PHP Operators: Array Operator
PHP Operators: Object Operator
PHP Operators: Operator Priority
PHP Constants: Introduction


Tag: operator, Assignment Operators Category: PHP Basic Post : March 08th 2008 Read: 1,882 Bookmark and Share

blog comments powered by Disqus