PHP从基本到入门(一)
<div style="color: black; text-align: left; margin-bottom: 10px;">
<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>为连载<span style="color: black;">文案</span>PHP入门的<span style="color: black;">第1</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>:<a style="color: black;">小白教你PHP<span style="color: black;">基本</span></a></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;"><strong style="color: blue;">算术运算符</strong></p>
<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;">符号有:+ - * / %</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">说明:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">1,<span style="color: black;">她们</span>都是针对数字进行的运算;</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">2,<strong style="color: blue;"><span style="color: black;">倘若</span><span style="color: black;">她们</span>的两边有不是数字的数据,就会(自动)转换为数字</strong>;</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">3,其中取余运算(取模运算)%,它只针对“整数”进行运算,<span style="color: black;">倘若</span>不是,会自动截取为整数。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">11. 3 % 3 相当于 11 % 3;</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">11.8 % 3. 8 相当于 11 % 3;</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;">常规:对数字进行自加1或自减1。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">字符串: 只能自增,且自增的效果<span style="color: black;">便是</span>“下一个字符”,其只能针对字母或数字进行自加:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">布尔值递增递减无效</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">null递减无效,递增结果为1</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">字符串自增的例子:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://p3-sign.toutiaoimg.com/b0f000764bb3966aa28~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1728299706&x-signature=g9HTo4zPpZZMXBxJ9mB4ZeeJnyg%3D" style="width: 50%; margin-bottom: 20px;"></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">前自增和后自增的区别(自减类似)</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://p3-sign.toutiaoimg.com/b9d000006313156d76e~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1728299706&x-signature=KJfCQEv7pqkaaKFoFgoD84cgi2A%3D" style="width: 50%; margin-bottom: 20px;"></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>在循环中,<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;">for($i = 1; $i < 10000; ++$i){ ....... }</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">演示前加加后加加进行1千万次的“效率比较”:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://p3-sign.toutiaoimg.com/b9d0000069713cecfaf~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1728299706&x-signature=xcjVjD2voZaqiuzfEHToH7XEQgo%3D" style="width: 50%; margin-bottom: 20px;"></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;">比较</strong><strong style="color: blue;">运算符</strong></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">符号:> >= < <= == != === !==</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>
<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>数据的类型和数据的值/内容,都相等,才是全等的)。必须能够找到手册的“类型比较表”:附录》php类型比较表:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://p3-sign.toutiaoimg.com/b9e0000669bbfc0dd5e~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1728299706&x-signature=aqEWINyvPIT2ozWSmaJJ8mny0HI%3D" style="width: 50%; margin-bottom: 20px;"></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://p3-sign.toutiaoimg.com/b9d000066df1c819406~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1728299706&x-signature=k%2BG1PgkwY%2FCHLTTKri8SJ24mrH0%3D" style="width: 50%; margin-bottom: 20px;"></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">不要对浮点数直接进行<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;"><span style="color: black;">平常</span><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>一个规则:true>false</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>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">否则,<span style="color: black;">倘若</span>两边都是“纯数字字符串”,转为数字比较</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">否则,就按字符串比较。字符串比较的规则是:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">对两边的字符串,一个一个从前往后取出字符并进行比较,谁“先大”,结果<span style="color: black;">便是</span>它大。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">“abc” > true //? false</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">“abc” > false //true</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">“0” > false //false</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">3 > “12”; //false</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">3 > “12abc”; //false</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">“3” > “12” //false</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">“abc” > “c”; //false,后者大</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">“abc” > “ab123cde”; //true <span style="color: black;">由于</span><span style="color: black;">这儿</span>”c”大于”1”</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">“3abc” > “12abc”; //true, <span style="color: black;">由于</span>”3”大于“1”</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">1 > “a”; //? true</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">“1” > “a” //? false</p>
<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>运算符都是针对“布尔值”进行的运算。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">倘若</span>不是布尔值,就会转换为布尔值进行;</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">布尔值<span style="color: black;">仅有</span>2个:true,false</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>与规则:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">true && true ==>> true</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">true && false ==>>false</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">false && true ==>>false</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">false && false ==>>false</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">总结:<span style="color: black;">仅有</span>2个都是true,结果才是true</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">只要有一个是false,结果<span style="color: black;">便是</span>false</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">规律</span>或规则:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">true || true ==>> true</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">true || false ==>>true</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">false || true ==>>true</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">false || false ==>>false</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">总结:<span style="color: black;">仅有</span>2个都是false,结果才是false</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">只要有一个是true,结果<span style="color: black;">便是</span>true</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">规律</span>非规则:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">!true ==>> false</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">!false ==>> true</p>
<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>与短路:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://p3-sign.toutiaoimg.com/b9e000066fdae3c8bbb~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1728299706&x-signature=b8Wcd3cY1kuzleGCvFE0446%2BKgs%3D" style="width: 50%; margin-bottom: 20px;"></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>与运算需要进行多项判断,<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>程度”,则<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>率的目的。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">规律</span>或短路:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://p3-sign.toutiaoimg.com/b9e000066fe1949fcaf~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1728299706&x-signature=KwjRR57Vls2YMc7wur4X%2FPKqrrA%3D" style="width: 50%; margin-bottom: 20px;"></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>或运算需要进行多项判断,<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>程度”,则<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>率的目的。</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;">1,符号<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;">2,含义:<span style="color: black;">便是</span>将这个符号两边的字符串连接起来;</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">3,<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;">“ab” . 3 ==>> “ab3”;</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">“12” . 3 ==>>”123”</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">12 . 3 ==>> “123”</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;">一个基本赋值运算符: =</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">形式: $变量名 = 值;</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">理解: 将右边的值(不管做了多少运算),赋值给左边的变量。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">若干个衍生的赋值运算符:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">+= 加等: 形式: $变量名 += 值;</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">理解: 相当于: $变量名 = $变量名 + 值;</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">-= 加等: 形式: $变量名 -= 值;</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">理解: 相当于: $变量名 = $变量名 - 值;</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>
<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>一个,形式如下:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">数据值1 ? 数据值2 : 数据值3</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">含义:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">对数据值1进行判断,<span style="color: black;">倘若</span>为“真”,则该运算符的运算结果<span style="color: black;">便是</span>数据值2,否则<span style="color: black;">便是</span>数据值3;</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>(<span style="color: black;">规律</span>判断)语句的简写形式:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">if( 数据值1 ){</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">$变量名 = 数据值2;</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">}</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">else{</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">$变量名 = 数据值3;</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">}</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>数据值1不是布尔值,<span style="color: black;">亦</span>会转换为布尔值;</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">$score = 66; //分数</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">$valuation = $score >= 60 ? “及格” : “不及格”; //结果为“及格”</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">$score = 56; //分数</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">$valuation = $score >= 60 ? “及格” : “不及格”; //结果为“不及格”</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">$score = 56; //分数</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">$valuation = $score ? “及格” : “不及格”; //结果为“及格”,<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;"><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;">1,位是什么?<span style="color: black;">便是</span>2进制数字的每一个“位”,一个整数数字,有(由)32个位<span style="color: black;">形成</span>!</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">2,位运算符是仅仅针对整数进行的运算符;</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">3,位运算符有如下几个</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">&: 按位与;</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">|: 按位或;</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">~: 按位非;按位取反;</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">^: 按位异或;</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">4,位运算符的基本语法规则:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">按位与基本规则:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">1 & 1 ==>> 1</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">1 & 0 ==>> 0</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">0 & 1 ==>> 0</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">0 & 0 ==>> 0</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">按位或基本规则:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">1 | 1 ==>> 1</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">1 | 0 ==>> 1</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">0 | 1 ==>> 1</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">0 | 0 ==>> 0</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">按位非基本规则:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">~1 ==>> 0</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">~0 ==>> 1</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">按位异或基本规则:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">1 ^ 1 ==>> 0</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">1 ^ 0 ==>> 1</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">0 ^ 1 ==>> 1</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">0 ^ 0 ==>> 0</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">可见,按位异或的规则是:相同为0,<span style="color: black;">区别</span>为1</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;">整数的</strong><strong style="color: blue;">按位与运算(&)</strong></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">形式:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">$n1 & $n2; //n1,n2是2个任意整数;</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">含义:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">将该2个整数的二进制数字形式(<span style="color: black;">重视</span>,都是32位)的每一个对应位上的数字进行基本按位与运算之后的结果!</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>运算的结果,其实仍然是一个普通的数字(10进制)。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">示例图示(只用8个位来演示):</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">$r1 = 10 & 20;</p>
<div style="color: black; text-align: left; margin-bottom: 10px;">
<div style="color: black; text-align: left; margin-bottom: 10px;">10的2进制0000101020的2进制00010100&运算结果:00000000</div>
</div>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">代码验证:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://p3-sign.toutiaoimg.com/b9d000068088a206bd2~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1728299706&x-signature=wyTtVXh94Ae2ufrqvgKMAZRVnWY%3D" style="width: 50%; margin-bottom: 20px;"></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;">形式:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">$n1 | $n2; //n1,n2是2个任意整数;</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">含义:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">将该2个整数的二进制数字形式(<span style="color: black;">重视</span>,都是32位)的每一个对应位上的数字进行基本按位或运算之后的结果!</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>运算的结果,其实仍然是一个普通的数字(10进制)。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">示例图示(只用8个位来演示):</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">$r1 = 10 | 20;</p>
<div style="color: black; text-align: left; margin-bottom: 10px;">
<div style="color: black; text-align: left; margin-bottom: 10px;">10的2进制0000101020的2进制00010100|运算结果:00011110</div>
</div>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">则结果该数据值<span style="color: black;">体积</span>为: 1*24 + 1 * 23 + 1*22 + 1* 21 + 0 = 16 + 8 + 4 + 2 = 30</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">代码验证:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://p3-sign.toutiaoimg.com/b0f0007c71f5a35b754~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1728299706&x-signature=Wwvyyg%2FTPfoBoFShajv9EF0HN3Q%3D" style="width: 50%; margin-bottom: 20px;"></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;">形式:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">$n1 << $m</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">含义:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">将十进制数字n1的二进制数字形式(<span style="color: black;">亦</span>是32位的)的每一个位上的数字都一次性往左边移动m位,</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">并将右边空出来的位置补0,左边冒出去的不管,<span style="color: black;">这般</span>操作之后得到的结果。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">示例图示(只用8个位来演示):</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">$r1 = 10 << 2;</p>
<div style="color: black; text-align: left; margin-bottom: 10px;">
<div style="color: black; text-align: left; margin-bottom: 10px;">10的2进制00001010左移2位后00101000则结果为:25023000</div>
</div>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">可见,结果为:25 + 23 = 32 + 8 = 40</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">代码验证:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://p3-sign.toutiaoimg.com/b9e0000683dd2daa183~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1728299706&x-signature=LocnOD%2FrietJV5ez%2FbrYKTU7oOY%3D" style="width: 50%; margin-bottom: 20px;"></p>
<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;">原码:</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>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">一个数字的最左边一位是“符号位”,0<span style="color: black;">暗示</span>正数,1<span style="color: black;">暗示</span>负数;</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">例如</span>:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://p3-sign.toutiaoimg.com/b0f0007c79cfb9d670f~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1728299706&x-signature=RZ5EDcVeIvGLYeub%2B2k%2BzQ%2FaQZI%3D" style="width: 50%; margin-bottom: 20px;"></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">反码:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">正数的反码<span style="color: black;">便是</span>其本身(即不变);</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">负数的反码是:符号位不变,其他位取反;</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">例如</span>:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://p3-sign.toutiaoimg.com/b9d000068ddac6fa3c9~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1728299706&x-signature=jO8flOgUvel6q7wm43hjpFOXtt8%3D" style="width: 50%; margin-bottom: 20px;"></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">补码:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">正数的补码<span style="color: black;">便是</span>其本身(即不变);</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">负数的补码是:符号位不变,其他位取反后+1——即反码+1</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://p3-sign.toutiaoimg.com/97d001641169772f575~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1728299706&x-signature=6VbA6LX8I2E%2BnwzPuxFu2IxFt%2Fc%3D" style="width: 50%; margin-bottom: 20px;"></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>补码进行的,<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;">示例1:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">5+3:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://p3-sign.toutiaoimg.com/b0f0007c804e30ab038~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1728299706&x-signature=WUrmaiykZUD%2B%2BYiXID%2Fn%2FdWI9T8%3D" style="width: 50%; margin-bottom: 20px;"></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">示例2: 5-3:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">实质</span>上,cpu内部,会将“减法”运算,转换为“加法运算”,即:5 + (-3)</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://p3-sign.toutiaoimg.com/b9e000068e0cf7329f2~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1728299706&x-signature=g9TyxayD3XGiA%2BolFTtLjjJ%2FWUI%3D" style="width: 50%; margin-bottom: 20px;"></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;">什么是开关状态?</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>2种结果(值)的,对应的其实<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;"><span style="color: black;">这儿</span>,<span style="color: black;">所说</span>管理一组事物的开关状态,应该理解为其实<span style="color: black;">便是</span>管理若干个<span style="color: black;">仅有</span>2个状态的“数据符号”。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">例如</span>:有5个灯泡,对应5个状态数据。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">这5个灯泡,就有 25 种状态呢?</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>是:<span style="color: black;">运用</span>一个变量,就<span style="color: black;">能够</span>表达若干个数据的“当前状态”。<span style="color: black;">详细</span>有3个任务:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">1,<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;">2,<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;">3,<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;">看代码!!!</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;">有这些:</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>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">将右边的数组项合并到左边数组的后面,得到一个新数组。如有重复键,则结果以左边的为准</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">$arr1 = array(5=>10, 8=>20, 10=>30);</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">$arr2 = array(3=>33, 2=>22);</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">$r1 = $arr1 + $arr2; //结果为:array(5=>10, 8=>20, 10=>30, 3=>33, 2=>22)</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">另一个有重复键的例子:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">$arr1 = array(5=>10, <strong style="color: blue;">8=>20</strong>, 10=>30);</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">$arr2 = array(<strong style="color: blue;">8=>33</strong>, 2=>22);</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">$r1 = $arr1 + $arr2; //结果为:array(5=>10, 8=>20, 10=>30, 2=>22)</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>相同的键名和键值(<span style="color: black;">能够</span><span style="color: black;">次序</span><span style="color: black;">区别</span>,或类型<span style="color: black;">区别</span>),则返回true</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">$arr1 = array(3=>33, 2=>22);</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">$arr2 = array(2=>”22”, 3=>”33” );</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">此时,$arr1,和 $arr2是相等的( = = )</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">!=</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>相同的键名和键值且<span style="color: black;">次序</span>和类型都一样,则返回true</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">!= =</p>
<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>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">$link = @mysql_connect(“数据库服务器<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;"><span style="color: black;">功效</span>是:</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>
<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;">运算符,都有优先级问题!</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">记住以下几条就<span style="color: black;">能够</span>了:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">要<span style="color: black;">认识</span>到运算符有优先级问题</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">括号最优先,赋值最落后(<span style="color: black;">一般</span>)</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">先乘除后加减</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">大致:单目运算符〉算术运算符〉比较运算符〉<span style="color: black;">规律</span>运算符(除了“非”运算)</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">能查到手册: 语言参考》运算符》运算符的优先级。</p>
<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;"><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>图形符号,以<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;"><img src="https://p3-sign.toutiaoimg.com/b9e0000697efa78f086~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1728299706&x-signature=DbtrYvIg7df1md11oUzwVMI3NpM%3D" style="width: 50%; margin-bottom: 20px;"></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;">if分支结构</strong></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">基本语法形式如下:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">if (<span style="color: black;">要求</span>判断1){</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">分支1;</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">}</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">else if (<span style="color: black;">要求</span>判断2){</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">分支2;</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">}</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">else if (<span style="color: black;">要求</span>判断3){</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">分支3;</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">}</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">。。。。。。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">else {</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">//else分支</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">}</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">说明:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">1,其中,绿色的else if部分<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;">2,其中,紫色的else部分<span style="color: black;">能够</span>完全省略。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">3,该if语句会从前往后(从上往下)依次判断<span style="color: black;">要求</span>,<span style="color: black;">倘若</span>某个<span style="color: black;">要求</span>满足了,就会执行其中对应的分支,<span style="color: black;">而后</span>就结束if分支结构语句!</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">4,<span style="color: black;">倘若</span>前面所有<span style="color: black;">要求</span>都不满足,就会执行最后的else分支(前提是有else分支)。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">图示如下:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://p3-sign.toutiaoimg.com/b0f0007c936f58d8dc5~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1728299706&x-signature=RxRyr2%2FNiMmkp3jaqH%2BoWvqVKK8%3D" style="width: 50%; margin-bottom: 20px;"></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;">switch分支结构</strong></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">形式:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">switch ( 表达式 ){</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">case <span style="color: black;">要求</span>值1:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">分支1;</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">【break;】 //是<span style="color: black;">能够</span>省略部分,不是语法所必须;</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">case <span style="color: black;">要求</span>值2:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">分支2;</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">【break;】 //是<span style="color: black;">能够</span>省略部分,不是语法所必须;</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">........</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">default :</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">default 分支;</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">}</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">说明:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">1,将表达式的结果数据,跟“<span style="color: black;">要求</span>值1”进行“相等判断”,<span style="color: black;">倘若</span>相等,就执行分支1,否则继续对后续值进行判断。。。。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">2,<span style="color: black;">倘若</span>某个分支判断为相等,则执行该分支语句后,并且<span style="color: black;">倘若</span>其中<span style="color: black;">无</span>break语句,则会直接进入下一个分支继续执行,而不会再去判断下一个分支的<span style="color: black;">要求</span>值了,并直到碰到break语句才会跳出。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">关系图如下所示:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://p3-sign.toutiaoimg.com/b0f0007c97d9aac3d3c~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1728299706&x-signature=QFZEM4qocuAa5jIy4ePx%2BfK1U0U%3D" style="width: 50%; margin-bottom: 20px;"></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">举例如下:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://p3-sign.toutiaoimg.com/b0f0007c97ce7fceb10~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1728299706&x-signature=II8u9UfyR1zdgjG%2BWhfF3S2tFyE%3D" style="width: 50%; margin-bottom: 20px;"></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">for循环结构</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://p3-sign.toutiaoimg.com/b9d00006ba99df03237~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1728299706&x-signature=pfQJ7nd34Rp9sxlaIOQ3eltf0mw%3D" style="width: 50%; margin-bottom: 20px;"></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="https://p3-sign.toutiaoimg.com/78f0019c921f277eb1f~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1728299706&x-signature=%2Fa7gYg5TvedzkO1vpJA2JWey1vw%3D" style="width: 50%; margin-bottom: 20px;"></p>
<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>素材及<span style="color: black;">更加多</span>课程请搜索<span style="color: black;">微X</span>公众号“爱搞机个人版”,<span style="color: black;">爱好</span>学习的<span style="color: black;">意见</span>关注下,所有课程免费! 点下关注不迷路!</strong></p>
</div>
页:
[1]