In PHP, you can convert a hexadecimal string to decimal through the hexdec function. The syntax of this function is "hexdec(hex_string)", where the parameter "hex_string" represents the hexadecimal number to be converted. .
Recommended: "PHP Video Tutorial"
hexdec() function converts hexadecimal to decimal.
Syntax
hexdec(hex_string)
Parameters
hex_string Required. Specifies the hexadecimal number to be converted.
Description
Returns the decimal number equivalent to the hexadecimal number represented by the hex_string parameter. hexdec() Converts a hexadecimal string to a decimal number. The maximum value that can be converted is 7ffffffff, which is 2147483647 in decimal. Starting with PHP 4.1.0, this function can handle large numbers, in which case it returns a float type.
hexdec() Replaces all non-hexadecimal characters encountered with 0. This way, all zeros on the left are ignored, but zeros on the right are included in the value.
Example
<?php echo hexdec("1e"); echo hexdec("a"); echo hexdec("11ff"); echo hexdec("cceeff"); ?>
Output:
30 10 4607 13430527
The above is the detailed content of How to convert php string to decimal. For more information, please follow other related articles on the PHP Chinese website!