PHP 赋值运算符示例

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

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程