首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

ctype_print

(PHP 4 >= 4.0.4, PHP 5, PHP 7)

ctype_print - 检查可打印字符(s)

描述

代码语言:javascript
复制
bool ctype_print ( string $text )

检查提供的字符串text中的所有字符是否可打印。

参数

text

被测试的字符串。

返回值

如果文本中的每个字符都实际创建输出(包括空白),则返回TRUE。 如果文本包含控制字符或根本没有任何输出或控制功能的字符,则返回FALSE。

例子

示例#1 一个ctype_print()示例

代码语言:javascript
复制
<?php
$strings?=?array('string1'?=>?"asdf\n\r\t",?'string2'?=>?'arf12',?'string3'?=>?'LKA#@%.54');
foreach?($strings?as?$name?=>?$testcase)?{
????if?(ctype_print($testcase))?{
????????echo?"The?string?'$name'?consists?of?all?printable?characters.\n";
????}?else?{
????????echo?"The?string?'$name'?does?not?consist?of?all?printable?characters.\n";
????}
}
?>

上面的例子将输出:

代码语言:javascript
复制
The string 'string1' does not consist of all printable characters.
The string 'string2' consists of all printable characters.
The string 'string3' consists of all printable characters.

注意

注意:如果提供了-128到255之间的整数,则它将被解释为单个字符的ASCII值(为了允许扩展ASCII范围中的字符,负值将被添加256)。任何其他整数都被解释为包含整数的十进制数字的字符串。

扩展内容

  • ctype_cntrl() - 检查控制字符(s)
  • ctype_graph() - 检查除空格以外的任何可打印字符
  • ctype_punct() - 检查任何不是空格或字母数字字符的可打印字符

← ctype_lower

ctype_punct →

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com