mb_ord

(PHP 7 >= 7.2.0, PHP 8)

mb_ordGet Unicode code point of character

說明

mb_ord(string $string, ?string $encoding = null): int|false

Returns the Unicode code point value of the given character.

This function complements mb_chr().

參數(shù)

string

A string

encoding

encoding 參數(shù)為字符編碼。如果省略或是 null,則使用內(nèi)部字符編碼。

返回值

The Unicode code point for the first character of string 或者在失敗時返回 false.

更新日志

版本 說明
8.0.0 現(xiàn)在 encoding 可以為 null。

范例

<?php
var_dump
(mb_ord("A""UTF-8"));
var_dump(mb_ord("??""UTF-8"));
var_dump(mb_ord("\x80""ISO-8859-1"));
var_dump(mb_ord("\x80""Windows-1252"));
?>

以上例程會輸出:


int(65)
int(128024)
int(128)
int(8364)

參見

  • mb_internal_encoding() - 設置/獲取內(nèi)部字符編碼
  • mb_chr() - Return character by Unicode code point value
  • IntlChar::ord() - Return Unicode code point value of character
  • ord() - 轉(zhuǎn)換字符串第一個字節(jié)為 0-255 之間的值