当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


PHP hexadec()用法及代码示例


PHP hexadecimal() 函数用于将十六进制数转换为十进制数。它将十六进制字符串的十进制等效值返回为十进制数。

用法:

number hexdec ( string $hex_string )
参数 描述 必需/可选
hex_string 要转换的十六进制字符串 Required

例子1

<?php
$nos="1e";
echo "Your number is:".$nos;
echo "<br>"."By using 'hexdec()' function your value is:".(hexdec($nos)); 
?>

输出:

Your number is:1e
By using 'floor()' function your value is:30

例子2

<?php
$nos="a";
echo "Your number is:".$nos;
echo "<br>"."By using 'hexdec()' function your value is:".(hexdec($nos)); 
?>

输出:

Your number is:a
By using 'hexdec()' function your value is:10

例子3

<?php
$nos="11ff";
echo "Your number is:".$nos;
echo "<br>"."By using 'hexdec()' function your value is:".(hexdec($nos)); 
?>

输出:

Your number is:11ff
By using 'floor()' function your value is:4607

示例 4

<?php
$nos="cceeff";
echo "Your number is:".$nos;
echo "<br>"."By using 'hexdec()' function your value is:".(hexdec($nos)); 
?>

输出:

Your number is:cceeff
By using 'hexdec()' function your value is:13430527






相关用法


注:本文由纯净天空筛选整理自 PHP hexadec() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。