IntlChar::ord()函數是PHP中的內置函數,用於返回給定字符的Unicode代碼點值。
用法:
int IntlChar::ord( $character )
參數:此函數接受一個必填的單個參數$character。此參數是Unicode字符。
返回值:它以整數形式返回Unicode代碼點值。
以下示例程序旨在說明PHP中的IntlChar::ord()函數:
程序1:
<?php
// PHP function to illustrate
// the use of IntlChar::ord()
// Input int codepoint value
var_dump(IntlChar::ord("4"));
// Input character codepoint value
var_dump(IntlChar::ord("B"));
// Input character codepoint value
var_dump(IntlChar::ord("b"));
//Input int codepoint value
var_dump(IntlChar::ord("2018"));
// Input character codepoint value
var_dump(IntlChar::ord("Geeks"));
// Input symbole codepoint value
var_dump(IntlChar::ord("@"));
// Input symbole codepoint value
var_dump(IntlChar::ord("*"));
// Input space codepoint value
var_dump(IntlChar::ord(" "));
?>
輸出:
int(52) int(66) int(98) NULL NULL int(64) int(42) int(32)
程序2:
<?php
// PHP function to illustrate the
// use of IntlChar::ord()
// Declare an array with
// different codepoint value
$arr = array("X",
"x",
"*",
"8",
"0",
" ",
"&",
")",
"99",
);
// For loop condition to check
// each character through function
foreach ($arr as $val) {
// Check each element as code point data
var_dump(IntlChar::ord($val));
}
?>
輸出:
int(88) int(120) int(42) int(56) int(48) int(32) int(38) int(41) NULL
相關文章:
參考: http://php.net/manual/en/intlchar.ord.php
相關用法
- d3.js d3.lab()用法及代碼示例
- PHP exp()用法及代碼示例
- PHP Ds\Map put()用法及代碼示例
- d3.js d3.hcl()用法及代碼示例
- PHP sin( )用法及代碼示例
- PHP abs()用法及代碼示例
- PHP cos( )用法及代碼示例
- PHP tan( )用法及代碼示例
- d3.js d3.map.set()用法及代碼示例
- PHP next()用法及代碼示例
- PHP Ds\Map get()用法及代碼示例
- d3.js d3.sum()用法及代碼示例
注:本文由純淨天空篩選整理自jit_t大神的英文原創作品 PHP | IntlChar::ord() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。