【发布时间】:2013-08-16 09:34:16
【问题描述】:
我在 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的类型不对?
【问题讨论】:
标签: php comparison hex