PHP chr() 函数

PHP 教程 · 2019-01-29 10:42:38

实例

从不同 ASCII 值返回字符:

<?php
echo chr(52) . "<br>"; // Decimal value
echo chr(052) . "<br>"; // Octal value
echo chr(0x52) . "<br>"; // Hex value
?>

定义和用法

chr() 函数从指定 ASCII 值返回字符。

ASCII 值可被指定为十进制值、八进制值或十六进制值。八进制值被定义为带前置 0,十六进制值被定义为带前置 0x。

语法


chr(ascii)


参数 描述
ascii 必需。ASCII 值。

技术细节

返回值: 返回指定的字符。
PHP 版本: 4+

更多实例

实例 1

使用八进制值 046 来添加 ASCII 字符:&。

<?php
$str = chr(046);
echo("You $str me forever!");
?>

实例 2

使用十进制值 43 和 61 来添加 ASCII 字符:+ 和 =。

<?php
$str = chr(43);
$str2 = chr(61);
echo("2 $str 2 $str2 4");
?>

点击查看所有 PHP 教程 文章: https://codercto.com/courses/l/5.html

查看所有标签

Elements of Information Theory

Elements of Information Theory

Thomas M. Cover、Joy A. Thomas / Wiley-Blackwell / 2006-7 / GBP 76.50

The latest edition of this classic is updated with new problem sets and material The Second Edition of this fundamental textbook maintains the book's tradition of clear, thought-provoking instr......一起来看看 《Elements of Information Theory》 这本书的介绍吧!

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具