PHP ord()函数与示例
PHPord()方法
ord()函数是一个字符串函数,用于获取给定字符串第一个字符的ASCII码。
语法:
ord(string);
它接受字符串并返回数字值(ASCII码)。
例子:
Input: "Abc"
Output: 65PHP代码:
<?php
$str = "Abc";
echo ("ASCII code of first character is = " . ord($str) . "\n");
$str = "Hello world";
echo ("ASCII code of first character is = " . ord($str) . "\n");
$str = "_okay";
echo ("ASCII code of first character is = " . ord($str) . "\n");
$str = "123Hello";
echo ("ASCII code of first character is = " . ord($str) . "\n");
?>输出结果
ASCII code of first character is = 65 ASCII code of first character is = 72 ASCII code of first character is = 95 ASCII code of first character is = 49
热门推荐
10 儿子立冬祝福语简短独特
11 对当兵的祝福语简短
12 侄儿高考试祝福语简短
13 伴郎红包祝福语朋友简短
14 媳妇生日简短祝福语朋友
15 公司年会祝福语简短最好
16 元旦感恩祝福语简短大全
17 红包祝福语简短10字
18 周六早晨祝福语简短