作者tumc (HIHIHI)
看板Perl
標題[問題] 一個奇怪的問題...
時間Sun Jul 25 23:45:37 2010
$checkcode="abc";
if ($checkcode == ""){
print "ok1";
print $checkcode."\n";
}
為什麼if條件式成立的啊?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.44.242.236
推 flamerecca:字串比對不能用 == 吧? 07/26 00:03
推 zard1989:== 只能用在數字比對,"abc"和""轉換成數字都是0,故成立 07/26 03:49
→ zard1989:字串比對的話要用 eq 才行。 07/26 03:49