PHP 赋值运算符示例
尝试以下示例以了解所有的赋值运算符。将以下PHP程序复制并粘贴到test.php文件中,并将其放在您的PHP服务器的文档根目录中,然后使用任何浏览器浏览它。
<html>
<head>
<title>Assignment Operators</title>
</head>
<body>
<?php
a = 42;b = 20;
c =a + b; echo "Addtion Operation Result:c <br/>";
c +=a;
echo "Add AND Assigment Operation Result: c <br/>";c -= a;
echo "Subtract AND Assignment Operation Result:c <br/>";
c *=a;
echo "Multiply AND Assignment Operation Result: c <br/>";c /= a; echo "Division AND Assignment Operation Result:c <br/>";
c %=a;
echo "Modulus AND Assignment Operation Result: $c <br/>";
?>
</body>
</html>
这将产生以下结果−
Addtion Operation Result: 62
Add AND Assigment Operation Result: 104
Subtract AND Assignment Operation Result: 62
Multiply AND Assignment Operation Result: 2604
Division AND Assignment Operation Result: 62
Modulus AND Assignment Operation Result: 20