<?php
var_dump($isHoster); // prints int(0)
if ($isHoster == 'all')
$conditionsHoster = '0, 1';
else
$conditionsHoster = intval($isHoster);
var_dump($conditionsHoster); // prints string(4) "0, 1"
?>
Run Code Online (Sandbox Code Playgroud)
到底是怎么回事??谁可以解释一下?这从来没有发生在我身上......
0 == 'all'因为PHP会尝试把在PHP真正的'all'以int和(int) 'all'为0; 你应该写
if ($isHoster === 'all')
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
81 次 |
| 最近记录: |