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"; 

try link http://www.w3schools.com/php/func_string_chr.asp


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -