Assignment operator in Php


An operator is a symbol that represent a specific action.Operators are used to perform operations on variables and values.

Assignment operator
Assignment Operator is used to assign value to any variable. We can assign the value directly to the variable or after performing any operation we can assign value to variable. To assign value to variable '=' sign is used.
Example
<!DOCTYPE html>
<html>
<head><title>expertcodingmaster.com</title>
</head>
<body>
<?php
$a = 20;    // direct assignment
$b = $a + 10;  // assignment after operation
echo $b;
?>
</body>
</html>
Don't get confused while using single equal to( = ) sign or double equal to ( == ) sign. Single equal to sign is used for assignment but double equal to sign is used for compression

Output of the above code
30



No comments: