php - How to force string variable to evaluate to hex char in a string? -
i trying represent character hex value inside string. works if hex explicit not work when hex variable used:
$hex = '5a'; echo "hex explicit: \x5a, hex evaluated: \x$hex";
the output is:
hex explicit: z, hex evaluated: \x5a
the question - how modify \x$hex
z instead of \x5a
?
hope helps.
integer literals
<?php $a = 1234; // decimal number $a = -123; // negative number $a = 0123; // octal number (equivalent 83 decimal) $a = 0x1a; // hexadecimal number (equivalent 26 decimal) ?>
this answer
$hex = chr(0x5a); echo "hex explicit: \x5a, hex evaluated:".$hex;
or
$hex = chr(0x5a); echo "hex explicit: \x5a, hex evaluated: $hex";
Comments
Post a Comment