How to convert strings in hex format?



How to convert strings in hex format?..

Answer / Rizwan Alam Khan.

In PHP, you can convert a string to hexadecimal using the dechex() function and back to a string using hexdec(). Here's an example:nn```phpn$str = 'example';n$hex_string = dechex($str); // Convert string to hexadecimalnecho $hex_string; // Output: 656d6173706fn$str_back = pack('H*', $hex_string); // Convert hexadecimal back to a stringnecho $str_back; // Output: example``

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More PHP Interview Questions

What are the differences between public, private, protected, static, transient, final and volatile?

3 Answers  


How to uploaded files to a table?

1 Answers  


What is scope of variable in php?

1 Answers  


Which is better session or cookie?

1 Answers  


How to create database connection and query in php?

1 Answers  


Which function Returns the time of sunrise for a given day / location in PHP.

1 Answers  


Do you know what is the differences between $a != $B and $a !== $B?

1 Answers  


What is meant by nl2br()?

4 Answers   Rushmore Consultancy,


how to select the multiple data in selection button

1 Answers   xasis technologies,


What is api used for?

1 Answers  


Which is incorrect with respect to separating php code and html?

1 Answers  


What are psrs?

1 Answers  


Categories