Home Tutorial Php Phpbasics Tutorial PHP Assignment Operators

 
 

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

Advertisement

Related Tags for PHP Assignment Operators:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: March 19, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com