PHP Assignment Operators

In this tutorial we will study about PHP assignment operators, types of assignment operators, how to use the operators etc are given in the example, do it by yourself, you could make necessary modifications as well.

 
 

Share on Google+Share on Google+

PHP Assignment Operators

Ads

In this tutorial we will study about PHP assignment operators, types of assignment operators, how to use the operators etc are given in the example, do it by yourself, you could make necessary modifications as well.

Assignment Operator:

We  have used the basic assignment operator in our life but a confusion may occur between an "assignment operator" and "equal to ", though these seems same but in programming languages these are not.

In the following examples different types of assignment operators are described:

Example of PHP Assignment Operator:

<?php

$a=($b=23)+12;

echo "Value of a is :".$a."<br/>";

$a+=34;

echo "Value of a is :".$a."<br/>";

$a-=34;

echo "Value of a is :".$a."<br/>";

$a/=34;

echo "Value of a is :".$a."<br/>";

echo "Value in integer data type of a is :".(int)$a."<br/>";

$a*=34;

echo "Value of a is :".$a."<br/>";

$a%=34;

echo "Value of a is :".$a."<br/>";

echo "Value of b is :".$b;

?>

Output:

Value of a is :35
Value of a is :69
Value of a is :35
Value of a is :1.0294117647059
Value in integer data type of a is :1
Value of a is :35
Value of a is :1
Value of b is :23

Advertisements

Posted on: March 19, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles