comparison - How to compare a character with a hex value in php? -


i have following problem in php. want compare character (string) hex value, see following example code:

// key defined in other application. can use key1 define("key1", 0x31);  // test value $svalue = '1';  // comparison not modify print ($svalue == key1) ? "true" : "false"; 

as 0x31 represents 49 decimal character '1', expect see true. instead see false. how right without using different key1? maybe type of svalue incorrect?

you're looking for

print ($svalue == chr(key1)) ? "true" : "false"; 

or, alternatively,

print (ord($svalue) == key1) ? "true" : "false"; 

Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -