Q:

How do i convert an 8 bit binary data to hex

print_r(bin2hex("11111111"));
echo '</br>';
print_r(bindec("11111111"));

Result

131313131313131
255

I want a hexadecimal 16 byte value to do aes encryption. How is the conversion from binary to hex happening in php. I am getting incorrect value using the function. Also when i convert an array of hexadecimal values to string the byte length changes

A:

You get a correct result, it's just not what you want.  bin2hex() returns an ASCII string of the hexadecimal representation.  A quote from the manual:

Returns an ASCII string containing the hexadecimal representation of str. 

So If you want the hexadecimal number you can use this:
print_r(dechex(bindec("11111111")));

