Conversion method: 1. Use the base_convert() function to convert octal to hexadecimal, the syntax is "base_convert(octal string, 8,16)"; 2. Use the hex2bin() function to convert octal to hexadecimal. System to string, the syntax is "hex2bin (hexadecimal value)".
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
php converts octal to string
Implementation idea:
Use the base_convert() function to convert octal to hexadecimal
Use the hex2bin() function to convert hexadecimal to a string
<?php $oct = "6414533066157"; $hex = base_convert($oct,8,16); $str = hex2bin($hex); echo $str; ?>
Explanation: The
base_convert() function can be used in any Convert numbers between systems.
Syntax:
base_convert(number,frombase,tobase);
Parameters | Description |
---|---|
number | Required. Specifies the number to be converted. |
frombase | Required. Specifies the original base of the number. Between 2 and 36 (inclusive). Numbers above decimal are represented by the letters a-z, such as a for 10, b for 11, and z for 35. |
tobase | Required. Specifies the base to be converted. Between 2 and 36 (inclusive). Numbers above decimal are represented by the letters a-z, such as a for 10, b for 11, and z for 35. |
hex2bin() function converts a string of hexadecimal values into ASCII characters, which is an ordinary string.
Syntax:
hex2bin(string)
Parameters | Description |
---|---|
string | Required. The hexadecimal value to convert. |
Recommended study: "PHP Video Tutorial"
The above is the detailed content of How to convert octal to string in php. For more information, please follow other related articles on the PHP Chinese website!