English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The ctype_print() function performs printable character detection, checking if all characters in the string are printable characters.
ctype_print( $text );
This function checks if all characters in the provided string are printable.
Serial Number | Parameters and Description |
---|---|
1 | text (required) The string being tested. |
If all characters in the text can be actually output in the current language environment (including whitespace), it returns TRUE; if the text contains control characters or strings that will not output anything, it returns FALSE.
Check if all characters in the text are printable characters, note that the output of single quotes and double quotes in the following example is different
<?php $strings = array('asdf\n\r\t', "asdf\n\r\t", 'k211', "fooo#int%@") foreach ($strings as $test) { if (ctype_print($test)) { echo "$test All are printable characters \n"; }else { echo "$test Contains non-printable characters \n"; } } ?>Test and see‹/›
Output result:
asdf\n\r\t All are printable characters asdf Contains non-printable characters k211 All are printable characters fooo#int%@ All are printable characters