The Hexadecimal value cannot be a string representation, meaning that it has to be 0x1a form. Not '0x1a'.
Try the code below
Code: Select all
<?php
$real_hex_1 = 0x1a;
$real_hex_2 = "\x1a";
$hex_string = "abcdefghijklmnopqrstuvwxyz"; //26 characters
$fake_hex = dechex(strlen($hex_string));
echo "<br/>Real Hex #1 ==> $real_hex_1";
echo "<br/>Real Hex #2 ==> $real_hex_2";
echo "<br/>FAKE Hex ==> $fake_hex";
?>Example
Code: Select all
<?php
$hex_variable ='';
$hex_variable .=$real_hex_1;
$hex_variable .=$real_hex_2;
$hex_variable .=$fake_hex;
?>I am writing a WBXML Encoder and require to contruct a hexadecimal to send back to the Client.
If you think my thinking is wrong and that $fake_hex will work for the WBXML Decoder then this saves me alot of trouble because i don't have to worry about the 0x[a-z0-9]{1,2}.
If you think my thinking is wrong then try
Code: Select all
<?php
$real_hex ='';
$real_hex .= 0x05;
$real_hex .= 0x1a;
$real_hex .= 0x02;
$fake_hex='';
$fake_hex .= '0x05';
$fake_hex .= '0x1a';
$fake_hex .= '0x02';
$better_hex = '';
$better_hex .= "\x05";
$better_hex .= "\x1a";
$better_hex .= "\x02";
echo "Is $real_hex equal to $fake_hex?<br/> What i am asking for is a function that can give me the ability to concatenate real_hex or even better if i can get something that can give me $better_hex for concatenation";
?>Regards
Mian