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 老公开业祝福语简短
18 官宣新年祝福语简短