PHP bin2hex() Function
In this chapter you will learn:
- Definition for PHP bin2hex() Function
- Syntax for PHP bin2hex() Function
- Parameter for PHP bin2hex() Function
- Return for PHP bin2hex() Function
- Example - Convert binary to hexadecimal values
Definition
The bin2hex() function converts a string of binary to hexadecimal values.
Syntax
bin2hex() Function has the following syntax.
bin2hex(string)
Parameter
Parameter | Is Reqired | Description |
---|---|---|
string | Required. | The string to be converted |
Return
PHP bin2hex() function returns the hexadecimal string.
Example
Convert binary to hexadecimal values:
<?php
$str = bin2hex("11111001");
echo($str);
?>
The code above generates the following result.
Next chapter...
What you will learn in the next chapter:
- Definition for PHP chop() Function
- Syntax for PHP chop() Function
- Parameter for PHP chop() Function
- Return for PHP chop() Function
- Example - Remove characters from the right end of a string
- Example - Remove newlines (\n) from the right end of a string
Home » PHP Tutorial » PHP String Functions