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);
?> 鎵ц鍚庯紝姝よ剼鏈細鏄剧ず锛
 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<span style="font-size:14px;">Union of $a and $b:
array(3) {
  ["a"]=>
  string(5) "apple"
  ["b"]=>
  string(6) "banana"
  ["c"]=>
  string(6) "cherry"
}
Union of $b and $a:
array(3) {
  ["a"]=>
  string(4) "pear"
  ["b"]=>
  string(10) "strawberry"
  ["c"]=>
  string(6) "cherry"
}</span>

鏁扮粍涓殑鍗曞厓濡傛灉鍏锋湁鐩稿悓鐨勯敭鍚嶅拰鍊煎垯姣旇緝鏃剁浉绛夈
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浜戝叾瀹冪浉鍏虫枃绔狅紒



鏈枃URL锛http://www.odweb.cn/news_show.html?id=71