PHP閫掑/閫掑噺杩愮畻绗
PHP 鏀寔 C 椋庢牸鐨勫墠锛忓悗閫掑涓庨掑噺杩愮畻绗︺
閫掑锛忛掑噺杩愮畻绗Note: 閫掑锛忛掑噺杩愮畻绗︿笉褰卞搷甯冨皵鍊笺傞掑噺 NULL 鍊间篃娌℃湁鏁堟灉锛屼絾鏄掑 NULL 鐨勭粨鏋滄槸 1銆
渚嬪瓙 | 鍚嶇О | 鏁堟灉 |
---|---|---|
++$a | 鍓嶅姞 | $a 鐨勫煎姞涓锛岀劧鍚庤繑鍥 $a銆 |
$a++ | 鍚庡姞 | 杩斿洖 $a锛岀劧鍚庡皢 $a 鐨勫煎姞涓銆 |
--$a | 鍓嶅噺 | $a 鐨勫煎噺涓锛 鐒跺悗杩斿洖 $a銆 |
$a-- | 鍚庡噺 | 杩斿洖 $a锛岀劧鍚庡皢 $a 鐨勫煎噺涓銆 |
涓涓畝鍗曠殑绀轰緥鑴氭湰锛
<?php
echo "<h3>Postincrement</h3>";
$a = 5;
echo "Should be 5: " . $a++ . "<br /> ";
echo "Should be 6: " . $a . "<br /> ";
echo "<h3>Preincrement</h3>";
$a = 5;
echo "Should be 6: " . ++$a . "<br /> ";
echo "Should be 6: " . $a . "<br /> ";
echo "<h3>Postdecrement</h3>";
$a = 5;
echo "Should be 5: " . $a-- . "<br /> ";
echo "Should be 4: " . $a . "<br /> ";
echo "<h3>Predecrement</h3>";
$a = 5;
echo "Should be 4: " . --$a . "<br /> ";
echo "Should be 4: " . $a . "<br /> ";
?>
鍦ㄥ鐞嗗瓧绗﹀彉閲忕殑绠楁暟杩愮畻鏃讹紝PHP 娌胯浜 Perl 鐨勪範鎯紝鑰岄潪 C 鐨勩備緥濡傦紝鍦 Perl 涓 'Z'+1 灏嗗緱鍒 'AA'锛岃屽湪 C 涓紝'Z'+1 灏嗗緱鍒 '['锛坥rd('Z') == 90锛宱rd('[') == 91锛夈傛敞鎰忓瓧绗﹀彉閲忓彧鑳介掑锛屼笉鑳介掑噺锛屽苟涓斿彧鏀寔绾瓧姣嶏紙a-z 鍜 A-Z锛夈
Example #1 娑夊強瀛楃鍙橀噺鐨勭畻鏁拌繍绠
<?php$i = 'W';
for ($n=0; $n<6; $n++) {
echo ++$i . " ";
}
?>
浠ヤ笂渚嬬▼浼氳緭鍑猴細
1
2
3
4
5
6
|
X
Y
Z
AA
AB
AC
|
閫掑鎴栭掑噺甯冨皵鍊兼病鏈夋晥鏋溿
浠ヤ笂灏辨槸PHP閫掑/閫掑噺杩愮畻绗︾殑璇︾粏鍐呭锛屾洿澶氫俊鎭鍏虫敞OD浜戝叾瀹冪浉鍏虫枃绔狅紒