dechex()是PHP中的內置函數,用於將給定的十進製數轉換為等效的十六進製數。函數名稱中的單詞“ dechex”代表十進製到十六進製。 dechex()函數僅適用於無符號數字。如果傳遞給它的參數為負,則將其視為無符號數字。
可以轉換的最大數字是十進製的4294967295,結果為“ffffffff”。
用法:
string dechex($value)
參數:該函數接受單個參數$value。它是您要轉換為十六進製表示形式的十進製數字。
返回值:它返回作為參數傳遞給它的數字的十六進製字符串表示形式。
例子:
Input : dechex(10) Output : a Input : dechex(47) Output : 2f Input : dechex(4294967295) Output : ffffffff
以下示例程序旨在說明PHP中的dechex()函數:
- 傳遞10作為參數:
<?php echo dechex(10); ?>
輸出:
a
- 傳遞47作為參數:
<?php echo dechex(47); ?>
輸出:
2f
- 當最大可能的十進製數作為參數傳遞時:
<?php echo dechex(4294967295); ?>
輸出:
ffffffff
參考:
http://php.net/manual/en/function.dechex.php
相關用法
- p5.js pow()用法及代碼示例
- PHP pow( )用法及代碼示例
- p5.js day()用法及代碼示例
- p5.js abs()用法及代碼示例
- PHP next()用法及代碼示例
- p5.js cos()用法及代碼示例
- p5.js sq()用法及代碼示例
- d3.js d3.map.has()用法及代碼示例
- p5.js value()用法及代碼示例
- PHP Ds\Map get()用法及代碼示例
- PHP each()用法及代碼示例
- p5.js hex()用法及代碼示例
注:本文由純淨天空篩選整理自Shubrodeep Banerjee大神的英文原創作品 PHP | dechex() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。