當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。