6hz7vif 发表于 2024-10-5 10:24:01

讲清楚PHP的运算符


    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">这儿</span>我虽然讲的是PHP运算符,但编程语言的运算符大多都<span style="color: black;">同样</span>,<span style="color: black;">能够</span><span style="color: black;">做为</span>参考</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;">算术运算符</strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">生活中<span style="color: black;">咱们</span>常用的运算符<span style="color: black;">便是</span><strong style="color: blue;">算术运算符</strong>中的加减乘除,<span style="color: black;">因此</span><span style="color: black;">咱们</span>先讲算术运算符</p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/eb988e3f1a8344daaaa9012b4e31ef44~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1728303669&amp;x-signature=eyALidfxDy5N0iS1UZmZnJk1Pk4%3D" style="width: 50%; margin-bottom: 20px;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">算术运算符</p>
    </div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">这<span style="color: black;">便是</span><span style="color: black;">咱们</span>用的算术运算符,你可能会问<span style="color: black;">为何</span><span style="color: black;">无</span>开根号?PHP里开根号是用函数来实现的</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;">赋值运算符</strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">赋值运算符是编程语言里最常用的运算符,<span style="color: black;">例如</span>上面的$c=$a+$b;<strong style="color: blue;">等于号</strong><span style="color: black;">便是</span>赋值运算符</p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/b35bb90e24e04a71bc368eb505f225bd~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1728303669&amp;x-signature=XF4M%2Fd0tePW2%2F7hMLGU5YqV%2B%2BbM%3D" style="width: 50%; margin-bottom: 20px;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">引用赋值</p>
    </div>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/bdc4b1b9b40e49d0be7c6fe22e1c4d9c~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1728303669&amp;x-signature=S8mhOjSZlIG1mu50pf6O8O94d3c%3D" style="width: 50%; margin-bottom: 20px;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">常用的赋值简写</p>
    </div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">刚忘了说有个常用的运算符<span style="color: black;">便是</span>++(递增)和--(递减),++和--赋值是有前后<span style="color: black;">次序</span>的</p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/0e7a73823e9346729da6c82fee6eb990~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1728303669&amp;x-signature=1r2Et5G4yaiTk5IBK8Z21ChJ%2FGw%3D" style="width: 50%; margin-bottom: 20px;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">重视</span>前后<span style="color: black;">次序</span></p>
    </div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;">位运算符</strong></p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/92794a67c29745c58877a51a5df669f2~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1728303669&amp;x-signature=4A%2BMMf4IsEx5rWyK3%2B5MpZIudUY%3D" style="width: 50%; margin-bottom: 20px;"></div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">位运算符说的是对<strong style="color: blue;">二进制</strong>进行运算,<span style="color: black;">重点</span>运算符为 与&amp; 或| 异或^ 取反~ 位移&lt;&lt;&gt;&gt;</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">位运算还牵扯到操作系统是64位还是32位,这个以后我再讲</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;">比较运算符</strong></p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/20897d7b045b4e2e9bc08f152406a223~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1728303669&amp;x-signature=VtNlYDvRs%2FTGbYDbTsXWZzSpAl8%3D" style="width: 50%; margin-bottom: 20px;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">比较运算符</p>
    </div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">比较运算符<span style="color: black;">便是</span><span style="color: black;">咱们</span><span style="color: black;">平常</span>说的 大于 <span style="color: black;">少于</span> 等于 , <span style="color: black;">运用</span>时<span style="color: black;">重视</span>的是 <strong style="color: blue;">全等于 不全等于 组合比较符</strong>, PHP里 等于和全等于的区别在于,<strong style="color: blue;">全等于</strong>两边数据的类型<span style="color: black;">亦</span>要<span style="color: black;">同样</span>,否则返回false,<strong style="color: blue;">等于</strong>则相对宽松点</p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/438c60d041234b2e847fab1d1f3d60c2~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1728303669&amp;x-signature=cpEUCnWDk1fIC6ui%2FYv%2BhI8odBs%3D" style="width: 50%; margin-bottom: 20px;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">等于和全等于</p>
    </div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">组合比较符是方便返回大于等于<span style="color: black;">少于</span>,-1<span style="color: black;">便是</span><span style="color: black;">少于</span>0<span style="color: black;">便是</span>等于1就是大于</p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/cbb923362faa4646be57632a61b4ef08~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1728303669&amp;x-signature=mirbmV%2Bbjf%2FmM4Myn%2FmpiZBwj0Q%3D" style="width: 50%; margin-bottom: 20px;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">组合比较符</p>
    </div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;">执行运算符</strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">其实<span style="color: black;">便是</span>shell_exec的方便写法,用反引号`来引用命令</p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/4f881d36b30e4c8da3b44849cb2b44d6~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1728303669&amp;x-signature=HQyENaMT4kVeOPlkM9MBmxJY33Q%3D" style="width: 50%; margin-bottom: 20px;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">执行运算符</p>
    </div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">规律</span>运算符</strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">规律</span>运算符和位运算很像,但不是一回事,<span style="color: black;">规律</span>运算符很常用</p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/e3987a3962b14ff4911ee9a7aa90e77e~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1728303669&amp;x-signature=tivkOVuYccRNX5kIVDtsTAtodCk%3D" style="width: 50%; margin-bottom: 20px;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">规律</span>运算符</p>
    </div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;">字符运算符</strong></p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/4a770006cf03430ca77d2f9344fd53dd~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1728303669&amp;x-signature=AdNuPeW1p8k1QbRAt720dsHy188%3D" style="width: 50%; margin-bottom: 20px;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">字符运算符</p>
    </div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;">数组运算符</strong></p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/7ba7652ece3543e4b8d45a941433666f~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1728303669&amp;x-signature=Gi1dgA0H3Y3r9Ys0TazZvawC7nE%3D" style="width: 50%; margin-bottom: 20px;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">数组运算</p>
    </div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">是不是很方便?<strong style="color: blue;">但数组运算是<span style="color: black;">次序</span>的</strong>,<span style="color: black;">这儿</span>的$a+$b,<span style="color: black;">倘若</span>写成$b+$a,结果就不<span style="color: black;">同样</span>了,<span style="color: black;">大众</span><span style="color: black;">能够</span>试试</p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/29a0f5f5e0ad40319f4dad5042b8d8ed~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1728303669&amp;x-signature=IMMWSBIZVFHriJMvOPH6lbDQDN8%3D" style="width: 50%; margin-bottom: 20px;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">亦</span><span style="color: black;">能够</span>做数组比较</p>
    </div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;">类型运算符</strong></p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/ca12eb85d24d4ac398040db66b7aa8b4~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1728303669&amp;x-signature=bqVviBzzoQ%2F%2FDtb%2BX4YRbXJJ%2Fks%3D" style="width: 50%; margin-bottom: 20px;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">类型运算符</p>
    </div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">instanceof 用于确定一个 PHP 变量<span style="color: black;">是不是</span>属于某一类 class 的实例</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">总结:运算符是PHP编程里常用的语法,<span style="color: black;">熟悉</span>应用是学好编程的<span style="color: black;">第1</span>步</p>




1fy07h 发表于 2024-10-7 01:58:57

我赞同你的看法,你的智慧让人佩服,谢谢分享。

b1gc8v 发表于 2024-10-29 02:08:20

论坛是一个舞台,让我们在这里尽情的释放自己。

wrjc1hod 发表于 前天 07:03

外贸网站建设方法 http://www.fok120.com/
页: [1]
查看完整版本: 讲清楚PHP的运算符