I would still like to know the proper syntax for comparing hex values, though.
In a way, there's no such thing as a hex value. 0x20 is 32 in hexadecimal representation, but whether it be in decimal, octal or hexadecimal representation, it is still the same number.
dechex() takes an integer and returns a string of the hexadecimal representation of the number. This is not a numeric value, but a string value. Now, PHP can automagically convert between these types, but dechex() does not include the hexadecimal notation prefix (0x) in the return value.
So if you do want to compare, you would use:
dechex(ord(" ")) == 20
But this is obviously going to be confusing, since you actually mean:
dechex(ord(" ")) == "20"
Hence there's no point using dechex() in the first place when you intend to compare with an integer.