IntlChar::totitle()函數是PHP中的內置函數,用於檢查輸入代碼點是否為Unicode字符標題。
用法:
mixed IntlChar::totitle( $codepoint )
參數:該函數接受單個參數$codepoint,該參數是必需的。 $codepoint參數是一個字符或整數值,編碼為UTF-8字符串。
返回值:返回代碼點的simple_Titlecase_Mapping(如果有);否則代碼本身。除非代碼點作為UTF-8字符串傳遞,否則返回類型將為整數,在這種情況下將返回字符串。
以下示例程序旨在說明PHP中的IntlChar::totitle()函數:
程序1:
<?php
// PHP function to illustrate the
// use of IntlChar::totitle()
// Input Capital letter codepoint
var_dump(IntlChar::totitle("G"));
// Input Capital letter codepoint
var_dump(IntlChar::totitle("g"));
// Input Capital letter codepoint
var_dump(IntlChar::totitle("a"));
// Input int char an identifier
// of codepoint value
var_dump(IntlChar::totitle("\u{00A0}"));
// Input symbolic space codepoint value
var_dump(IntlChar::totitle(" "));
// Input symbolic codepoint value
var_dump(IntlChar::totitle(" ^ "));
// Input int codepoint value
var_dump(IntlChar::totitle("9"));
// Input control character codepoint value
var_dump(IntlChar::totitle("\n"));
// Input character value
// return its ASCII value
var_dump(IntlChar::totitle(ord("D")));
var_dump(IntlChar::totitle(ord("d")));
// Input ASCII value 0054 is "T"
var_dump(IntlChar::totitle(ord("0054")));
var_dump(IntlChar::totitle(ord("@")));
?>
輸出:
string(1) "G" string(1) "G" string(1) "A" string(2) " " string(1) " " NULL string(1) "9" string(1) " " int(68) int(68) int(48) int(64)
程序2:
<?php
// PHP function to illustrate the
// use of IntlChar::totitle()
// Declare an array with
// different codepoint value
$arr = array("X",
"x",
"*",
"8",
"0",
" ",
);
// For loop condition to check
// each character through function
foreach ($arr as $val) {
// Check each element as code point data
var_dump(IntlChar::totitle($val));
}
?>
輸出:
string(1) "X" string(1) "X" string(1) "*" string(1) "8" string(1) "0" string(1) " "
相關文章:
參考: http://php.net/manual/en/intlchar.totitle.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::totitle() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。