dechex() 是預定義的 PHP 數學函數,用於將十進製數轉換為十六進製數。
用法:
string dechex ( int $number );
參數 | 描述 | 必需/可選 |
---|---|---|
number | 指定十進製值 | Required |
例子1
<?php
$decimal=7;
echo "Your Decimal number is:".$decimal."<br>";
echo "By using 'dechex()'function, your Hexadecimal number is:".dechex($decimal);
?>
輸出:
Your Decimal number is:7 By using 'dechex()'function, your Hexadecimal number is:7
例子2
<?php
$decimal=10;
echo "Your Decimal number is:".$decimal."<br>";
echo "By using 'dechex()'function, your Hexadecimal number is:".dechex($decimal);
?>
輸出:
Your Decimal number is:10 By using 'dechex()'function, your Hexadecimal number is:a
例子3
<?php
$decimal=30;
echo "Your Decimal number is:".$decimal."<br>";
echo "By using 'dechex()'function, your Hexadecimal number is:".dechex($decimal);
?>
輸出:
Your Decimal number is:30 By using 'dechex()'function, your Hexadecimal number is:1e
示例 4
<?php
$decimal=1587;
echo "Your Decimal number is:".$decimal."<br>";
echo "By using 'dechex()'function, your Hexadecimal number is:".dechex($decimal);
?>
輸出:
Your Decimal number is:1587 By using 'dechex()'function, your Hexadecimal number is:633
例 5
<?php
$decimal=70;
echo "Your Decimal number is:".$decimal."<br>";
echo "By using 'dechex()'function, your Hexadecimal number is:".dechex($decimal);
?>
輸出:
Your Decimal number is:70 By using 'dechex()'function, your Hexadecimal number is:46
例 6
<?php
// The output below assumes a 32-bit platform.
// Note that the output is the same for all values.
echo dechex(-1)."\n";
echo dech ex(PHP_INT_MAX * 2 + 1)."\n";
echo dechex(pow(2, 32) - 1)."\n";
?>
輸出:
ffffffff ffffffff ffffffff
相關用法
- PHP dechex( )用法及代碼示例
- PHP decbin()用法及代碼示例
- PHP decoct()用法及代碼示例
- PHP decbin( )用法及代碼示例
- PHP decoct( )用法及代碼示例
- PHP deg2rad()用法及代碼示例
- PHP defined()用法及代碼示例
- PHP disk_total_space( )用法及代碼示例
- PHP dir()用法及代碼示例
- PHP date_default_timezone_set()用法及代碼示例
- PHP date_timezone_set()用法及代碼示例
- PHP date_get_last_errors()用法及代碼示例
- PHP date_offset_get()用法及代碼示例
- PHP date_create()用法及代碼示例
- PHP date_parse()用法及代碼示例
- PHP date_diff()用法及代碼示例
- PHP date_default_timezone_get()用法及代碼示例
- PHP date_isodate_set()用法及代碼示例
- PHP date_timestamp_set()用法及代碼示例
- PHP date_time_set()用法及代碼示例
注:本文由純淨天空篩選整理自 PHP dechex() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。