Converting Strings to Hex Numbers in PHP

Q

How To Convert Strings to Hex Numbers?

✍: FYIcenter.com

A

If you want convert a string into hex format, you can use the bin2hex() function. Here is a PHP script on how to use bin2hex():

<?php
$string = "Hello\tworld!\n";
print($string."\n");
print(bin2hex($string)."\n");
?>

This script will print:

Hello   world!

48656c6c6f09776f726c64210a

 

Generating Character from ASCII Value in PHP

Comparing Two Strings with strcmp() in PHP

PHP Built-in Functions for Strings

⇑⇑ PHP Tutorials

2016-10-13, 2426🔥, 0💬