PHP Assignment Operators

PHP Arithmetic Operators Previous Next PHP Comparison Operators


PHP Assignment Operators. The PHP assignment operators is used to assign a new value to variables in javascript.

#
Operator
Description
Example
1
=
Assign value
A = B
2
+=
Add and assign new value
A += B
3
-=
Substract and assign new value
A -= B
4
*=
Multiply and assign new value
A *= B
5
/=
Divide and assign new value
A /= B
6
%=
Modulus and assign new value
A %= B

Filename: php / assignment.php


Code
<?php
//assignment
$a = 70;
$b;
$a = $b;
echo $a;
?>

Running Step.


Type URL - https://localhost/php/assignment.php

Output
70

Filename: php / assignment1.php


Code
<?php
//assignment1
$a = 80;
$a += 73;
echo $a;
?>

Running Step.


Type URL - https://localhost/php/assignment1.php

Output
153

Filename: php / assignment2.php


Code
<?php
//assignment2
$a = 703;
$a -= 47;
echo $a;
?>

Running Step.


Type URL - https://localhost/php/assignment2.php

Output
656

Filename: php / assignment3.php


Code
<?php
//assignment3
$a = 45;
$a *= 69;
echo $a;
?>

Running Step.


Type URL - https://localhost/php/assignment3.php

Output
3105

Filename: php / assignment4.php


Code
<?php
//assignment4
$a = 240;
$a /= 94;
echo $a;
?>

Running Step.


Type URL - https://localhost/php/assignment4.php

Output
2.5531914893617

Filename: php / assignment5.php


Code
<?php
//assignment5
$a = 22;
$a %= 75;
echo $a;
?>

Running Step.


Type URL - https://localhost/php/assignment5.php

Output
22

Tags: PHP


Was this helpful ?


Popular Code

Latest Code