PHP鏁扮粍杩愮畻绗
渚嬪瓙 | 鍚嶇О | 缁撴灉 |
---|---|---|
$a + $b | 鑱斿悎 | $a 鍜 $b 鐨勮仈鍚堛 |
$a == $b | 鐩哥瓑 | 濡傛灉 $a 鍜 $b 鍏锋湁鐩稿悓鐨勯敭锛忓煎鍒欎负 TRUE銆 |
$a === $b | 鍏ㄧ瓑 | 濡傛灉 $a 鍜 $b 鍏锋湁鐩稿悓鐨勯敭锛忓煎骞朵笖椤哄簭鍜岀被鍨嬮兘鐩稿悓鍒欎负 TRUE銆 |
$a != $b | 涓嶇瓑 | 濡傛灉 $a 涓嶇瓑浜 $b 鍒欎负 TRUE銆 |
$a <> $b | 涓嶇瓑 | 濡傛灉 $a 涓嶇瓑浜 $b 鍒欎负 TRUE銆 |
$a !== $b | 涓嶅叏绛 | 濡傛灉 $a 涓嶅叏绛変簬 $b 鍒欎负 TRUE銆 |
+ 杩愮畻绗︽妸鍙宠竟鐨勬暟缁勫厓绱狅紙闄ゅ幓閿间笌宸﹁竟鐨勬暟缁勫厓绱犵浉鍚岀殑閭d簺鍏冪礌锛夐檮鍔犲埌宸﹁竟鐨勬暟缁勫悗闈紝浣嗘槸閲嶅鐨勯敭鍊间笉浼氳瑕嗙洊銆
<?php
$a = array("a" => "apple", "b" => "banana");
$b = array("a" => "pear", "b" => "strawberry", "c" => "cherry");
$c = $a + $b; // Union of $a and $b
echo "Union of $a and $b: ";
var_dump($c);
$c = $b + $a; // Union of $b and $a
echo "Union of $b and $a: ";
var_dump($c);
?> 鎵ц鍚庯紝姝よ剼鏈細鏄剧ず锛
|
鏁扮粍涓殑鍗曞厓濡傛灉鍏锋湁鐩稿悓鐨勯敭鍚嶅拰鍊煎垯姣旇緝鏃剁浉绛夈
Example #1 姣旇緝鏁扮粍
<?php
$a = array("apple", "banana");
$b = array(1 => "banana", "0" => "apple");
var_dump($a == $b); // bool(true)
var_dump($a === $b); // bool(false)
?>
鍙傝鏁扮粍绫诲瀷鍜屾暟缁勫嚱鏁扮珷鑺傘
浠ヤ笂灏辨槸PHP鏁扮粍杩愮畻绗︾殑璇︾粏鍐呭锛屾洿澶氫俊鎭鍏虫敞OD浜戝叾瀹冪浉鍏虫枃绔狅紒