<?php /*运算符号(PHP)操作符号 * * 按运算符号功能分为: * 一、算术运算符 + - * / % ++ -- * 二、字符串运算符 . 连接运算符 * 三、赋值运算符 = += -= *= /= %= .= * 四、比较运算符 > < >= <= == === != <> !== * 比较运算符---条件运算符---关系运算符 * 比较后的结果只有一种:boolean true false * === 比较时不仅要求内容相同,也要求类型相同 * !== 比较时内容不相同,也要求类型不相同 * 五、逻辑运算符 &&或and ||或or !或not * 逻辑运算符只能操作bool型的值,返回的也是bool型的值 * 六、位运算符 & | ^ ~ << >> >>> * 七、其他运算符 ? : `` @ => -> :: & $ * `` 用来执行操作系统内核 * @ 用来屏蔽掉错误信息 * 建议使用"()"改变表达式的优先级别 * * % 有两个目的:整除运算;控制范围,不要用小数,也不要用负数 * % 会吧运算符两边的数转为整数后再进行整除求余。 */ //用 %符号判断闰年 $year = 2011; if (($year % 4 == 0 && % year % 100 != 0) || $year % 400 = 0) { echo "run nian"; } else { echo " not run nian"; } // ++ --符号的使用 $a = 10; $a++; //$a=$a+1; 先用变量,再自增1 ++$a; //$a=$a+1; 先自增1,在用变量 $a--; //$a=$a-1; 先用变量,再自减1 --$a; //$a=$a-1; 先自减1,再用变量 echo $a; //结果为10 //++ -- 运算的区别 $a = 10; $b = $a++; //b=10,a=11 $c = --$b; //c=9,b=9 $d = $c++ + ++$c; //d=20,c=11 $e = $d-- - --$d; //d=18,e=2 echo $d; //字符串运算符 . 的使用 $name = "tom"; $age = 27; $height = 1.75; echo "我的名字是:{$name}我的年龄是:{$age}我的身高是:{$height}米<br>"; echo '我的名字是:' . $name . '我的年龄是:' . $age . '我的身高是:' . $height . '米' . '<br>'; echo "$age=" . $age; //$age=27 echo "我的名字是:{$name}我的年龄是:{$age}我的身高是:{$height}米<br>"; //赋值运算符的使用 $a = 10; $a+= 10; //$a=$a+10; $a-= 10; //$a=$a-10; $a*= 10; //... $a/= 10; //... $a%= 10; //$a=$a%10; $a.= "abc"; //$a=$a."abc"; echo $a; $str = '<table>'; $str.= '<tr>'; $str.= '<td>'; $str.= '</td>'; $str.= '</tr>'; $str.= '</table>'; echo $str; //输出一个表格 //比较运算符 var_dump(15 > 6); //返回 bool(true) $a = 15; if (15 == $a) { echo "a=15"; } else { echo "a!=15"; } //逻辑运算符的使用 var_dump(true && true); //true var_dump(true && false); //false var_dump(true || false); //true var_dump(!true); //false var_dump(!false); //true //判断用户名密码 $username = "admin"; $password = "123456"; $email = "290080604@qq.com"; if ($username == "admin" && $password = "123456") { echo "用户名密码正确"; } if ($username == "" || $password == "" || $email == "") { echo "一个都不能为空"; }
教程地址:
欢迎转载!但请带上文章地址^^

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.
