Home Tutorial Php Phpbasics Tutorial PHP Assignment Operators

 
 

PHP Assignment Operators
Posted on: March 19, 2010 at 12:00 AM
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

Related Tags for PHP Assignment Operators:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.