我在 PHP 中有以下问题。我想将一个字符(字符串)与一个十六进制值进行比较,请参见以下示例代码:
// some key defined in some other application. I only can use KEY1
define("KEY1", 0x31);
// the test value
$sValue = '1';
// the comparison which I would like not to modify
print ($sValue == KEY1) ? "true" : "false";
由于0x31
代表 49 个小数,即字符 ' 1
',我希望看到一个true
. 相反,我看到一个false
. 如何在不使用任何不同的情况下正确处理KEY1
?也许类型sValue
不正确?