= PHP_4_0_4, PHP_5, PHP_7, PHP_8 // ctype_alpha() - PHP_4 >= PHP_4_0_4, PHP_5, PHP_7, PHP_8 // ctype_cntrl() - PHP_4 >= PHP_4_0_4, PHP_5, PHP_7, PHP_8 // ctype_digit() - PHP_4 >= PHP_4_0_4, PHP_5, PHP_7, PHP_8 // ctype_graph() - PHP_4 >= PHP_4_0_4, PHP_5, PHP_7, PHP_8 // ctype_lower() - PHP_4 >= PHP_4_0_4, PHP_5, PHP_7, PHP_8 // ctype_print() - PHP_4 >= PHP_4_0_4, PHP_5, PHP_7, PHP_8 // ctype_punct() - PHP_4 >= PHP_4_0_4, PHP_5, PHP_7, PHP_8 // ctype_space() - PHP_4 >= PHP_4_0_4, PHP_5, PHP_7, PHP_8 // ctype_upper() - PHP_4 >= PHP_4_0_4, PHP_5, PHP_7, PHP_8 // ctype_xdigit() - PHP_4 >= PHP_4_0_4, PHP_5, PHP_7, PHP_8 // ============================== USING CLASSES (0) // ============================== USING DATA_TYPES (2) // bool // mixed // ============================== END // REQUIREMENTS // ============================== // ============================== BEGIN // PHP_VARIABLE_CTYPE // ============================== ABOUT // PHP Manual / Function Reference / Variable and Type Related Extensions / Ctype - Character type checking // URL: https://www.php.net/manual/en/book.ctype.php // ============================== DESCRIPTION // CHARACTER_TYPE_CHECKING // // CHARACTER_TYPE_CHECKING - BEGIN // Character type checking // // INTRODUCTION // INSTALLING_CONFIGURING // PREDEFINED_CONSTANTS // CTYPE_FUNCTIONS // // INTRODUCTION - BEGIN // Introduction // // The functions provided by this extension check whether a character or string falls into a certain character class according to the current locale (see also setlocale()). // When called with an integer argument these functions behave exactly like their C counterparts from ctype.h. It means that if an integer smaller than 256 is passed, it will use the ASCII value of it to see if it fits in the specified range (digits are in 0x30-0x39). If the number is between -128 and -1 inclusive then 256 will be added and the check will be done on that. // Warning: As of PHP 8.1.0, passing a non-string argument is deprecated. In the future, the argument will be interpreted as a string instead of an ASCII codepoint. Depending on the intended behavior, the argument should either be cast to string or an explicit call to chr() should be made. // When called with a string argument they will check every character in the string and will only return true if every character in the string matches the requested criteria. When called with an empty string the result will always be false. // Passing anything else but a string or integer will return false immediately. // It should be noted that ctype functions are always preferred over regular expressions, and even to some equivalent "str_*" and "is_*" functions. This is because of the fact that ctype uses a native C library and thus processes significantly faster. // Note: // These functions are not related to the Python "ctypes" library at all. The extension name stems from the ctype.h C header file that their C equivalents are defined in. // This extension also predates Python "ctypes" so any confusion caused by this naming is hardly PHP's fault. // // LITERATURE_SOURCES // * PHP_NET (2023-09-23) // URL: https://www.php.net/manual/en/intro.ctype.php // INTRODUCTION - END // // INSTALLING_CONFIGURING - BEGIN // Installing/Configuring // // REQUIREMENTS // INSTALLATION // RUNTIME_CONFIGURATION // RESOURCE_TYPES // // REQUIREMENTS - BEGIN // Requirements // // None besides functions from the standard C library which are always available. // // LITERATURE_SOURCES // * PHP_NET (2023-09-23) // URL: https://www.php.net/manual/en/ctype.requirements.php // REQUIREMENTS - END // // INSTALLATION - BEGIN // Installation // // This extension is enabled by default. It may be disabled by using the following option at compile time: --disable-ctype // The Windows version of PHP has built-in support for this extension. You do not need to load any additional extensions in order to use these functions. // // LITERATURE_SOURCES // * PHP_NET (2024-01-21) // URL: https://www.php.net/manual/en/ctype.installation.php // INSTALLATION - END // // RUNTIME_CONFIGURATION - BEGIN // Runtime Configuration // // This extension has no configuration directives defined in php.ini. // // LITERATURE_SOURCES // * PHP_NET (2023-09-23) // URL: https://www.php.net/manual/en/ctype.configuration.php // RUNTIME_CONFIGURATION - END // // RESOURCE_TYPES - BEGIN // Resource Types // // This extension has no resource types defined. // // LITERATURE_SOURCES // * PHP_NET (2023-09-23) // URL: https://www.php.net/manual/en/ctype.resources.php // RESOURCE_TYPES - END // // LITERATURE_SOURCES // * PHP_NET (2023-09-23) // URL: https://www.php.net/manual/en/ctype.setup.php // INSTALLING_CONFIGURING - END // // PREDEFINED_CONSTANTS - BEGIN // Predefined Constants // // This extension has no constants defined. // // LITERATURE_SOURCES // * PHP_NET (2023-09-23) // URL: https://www.php.net/manual/en/ctype.constants.php // PREDEFINED_CONSTANTS - END // // CTYPE_FUNCTIONS - BEGIN // Ctype Functions // // Table of Contents // * ctype_alnum - Check for alphanumeric character(s) // * ctype_alpha - Check for alphabetic character(s) // * ctype_cntrl - Check for control character(s) // * ctype_digit - Check for numeric character(s) // * ctype_graph - Check for any printable character(s) except space // * ctype_lower - Check for lowercase character(s) // * ctype_print - Check for printable character(s) // * ctype_punct - Check for any printable character which is not whitespace or an alphanumeric character // * ctype_space - Check for whitespace character(s) // * ctype_upper - Check for uppercase character(s) // * ctype_xdigit - Check for character(s) representing a hexadecimal digit // // LITERATURE_SOURCES // * PHP_NET (2023-09-23) // URL: https://www.php.net/manual/en/ref.ctype.php // CTYPE_FUNCTIONS - END // // LITERATURE_SOURCES // * PHP_NET (2023-09-23) // URL: https://www.php.net/manual/en/book.ctype.php // CHARACTER_TYPE_CHECKING - END // ============================== // ============================== BEGIN // PHP_VARIABLE_CTYPE_CTYPE_ALNUM // ============================== PUBLIC // ============================== ABOUT // Check for alphanumeric character(s). // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // ctype_alnum() - PHP_4 >= PHP_4_0_4, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_variable_ctype_ctype_alnum($text) { $return_ctype_alnum = false; // ========== CTYPE_ALNUM - BEGIN // ===== ABOUT // Check for alphanumeric character(s) // ===== DESCRIPTION // Checks if all of the characters in the provided string, text, are alphanumeric. // ===== SUPPORTED // PHP_4 >= PHP_4_0_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ctype_alnum(mixed $text): bool // ===== CODE $return_ctype_alnum = ctype_alnum( $text // mixed text - The tested string. // Note: If an int between -128 and 255 inclusive is provided, it is interpreted as the ASCII value of a single character (negative values have 256 added in order to allow characters in the Extended ASCII range). Any other integer is interpreted as a string containing the decimal digits of the integer. // Warning: As of PHP 8.1.0, passing a non-string argument is deprecated. In the future, the argument will be interpreted as a string instead of an ASCII codepoint. Depending on the intended behavior, the argument should either be cast to string or an explicit call to chr() should be made. ); // Return Values // Returns true if every character in text is either a letter or a digit, false otherwise. When called with an empty string the result will always be false. // // [examples] // Examples // [example] // Example #1 A ctype_alnum() example (using the default locale) // [php] // $strings = array('AbCd1zyZ9', 'foo!#$bar'); // foreach ($strings as $testcase) { // if (ctype_alnum($testcase)) { // echo "The string $testcase consists of all letters or digits.\n"; // } else { // echo "The string $testcase does not consist of all letters or digits.\n"; // } // } // [/php] // The above example will output: // [result] // The string AbCd1zyZ9 consists of all letters or digits. // The string foo!#$bar does not consist of all letters or digits. // [/result] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-21) // URL: https://www.php.net/manual/en/function.ctype-alnum.php // ========== CTYPE_ALNUM - END // SYNTAX: // bool ctype_alnum(mixed $text) return $return_ctype_alnum; // bool } // ============================== END // PHP_VARIABLE_CTYPE_CTYPE_ALNUM // ============================== // ============================== BEGIN // PHP_VARIABLE_CTYPE_CTYPE_ALPHA // ============================== PUBLIC // ============================== ABOUT // Check for alphabetic character(s). // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // ctype_alpha() - PHP_4 >= PHP_4_0_4, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_variable_ctype_ctype_alpha($text) { $return_ctype_alpha = false; // ========== CTYPE_ALPHA - BEGIN // ===== ABOUT // Check for alphabetic character(s) // ===== DESCRIPTION // Checks if all of the characters in the provided string, text, are alphabetic. In the standard C locale letters are just [A-Za-z] and ctype_alpha() is equivalent to (ctype_upper($text) || ctype_lower($text)) if $text is just a single character, but other languages have letters that are considered neither upper nor lower case. // ===== SUPPORTED // PHP_4 >= PHP_4_0_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ctype_alpha(mixed $text): bool // ===== CODE $return_ctype_alpha = ctype_alpha( $text // mixed text - The tested string. // Note: If an int between -128 and 255 inclusive is provided, it is interpreted as the ASCII value of a single character (negative values have 256 added in order to allow characters in the Extended ASCII range). Any other integer is interpreted as a string containing the decimal digits of the integer. // Warning: As of PHP 8.1.0, passing a non-string argument is deprecated. In the future, the argument will be interpreted as a string instead of an ASCII codepoint. Depending on the intended behavior, the argument should either be cast to string or an explicit call to chr() should be made. ); // Return Values // Returns true if every character in text is a letter from the current locale, false otherwise. When called with an empty string the result will always be false. // // [examples] // Examples // [example] // Example #1 A ctype_alpha() example (using the default locale) // [php] // $strings = array('KjgWZC', 'arf12'); // foreach ($strings as $testcase) { // if (ctype_alpha($testcase)) { // echo "The string $testcase consists of all letters.\n"; // } else { // echo "The string $testcase does not consist of all letters.\n"; // } // } // [/php] // The above example will output: // [result] // The string KjgWZC consists of all letters. // The string arf12 does not consist of all letters. // [/result] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-22) // URL: https://www.php.net/manual/en/function.ctype-alpha.php // ========== CTYPE_ALPHA - END // SYNTAX: // bool ctype_alpha(mixed $text) return $return_ctype_alpha; // bool } // ============================== END // PHP_VARIABLE_CTYPE_CTYPE_ALPHA // ============================== // ============================== BEGIN // PHP_VARIABLE_CTYPE_CTYPE_CNTRL // ============================== PUBLIC // ============================== ABOUT // Check for control character(s). // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // ctype_cntrl() - PHP_4 >= PHP_4_0_4, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_variable_ctype_ctype_cntrl($text) { $return_ctype_cntrl = false; // ========== CTYPE_CNTRL - BEGIN // ===== ABOUT // Check for control character(s) // ===== DESCRIPTION // Checks if all of the characters in the provided string, text, are control characters. Control characters are e.g. line feed, tab, escape. // ===== SUPPORTED // PHP_4 >= PHP_4_0_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ctype_cntrl(mixed $text): bool // ===== CODE $return_ctype_cntrl = ctype_cntrl( $text // mixed text - The tested string. // Note: If an int between -128 and 255 inclusive is provided, it is interpreted as the ASCII value of a single character (negative values have 256 added in order to allow characters in the Extended ASCII range). Any other integer is interpreted as a string containing the decimal digits of the integer. // Warning: As of PHP 8.1.0, passing a non-string argument is deprecated. In the future, the argument will be interpreted as a string instead of an ASCII codepoint. Depending on the intended behavior, the argument should either be cast to string or an explicit call to chr() should be made. ); // Return Values // Returns true if every character in text is a control character from the current locale, false otherwise. When called with an empty string the result will always be false. // // [examples] // Examples // [example] // Example #1 A ctype_cntrl() example // [php] // $strings = array('string1' => "\n\r\t", 'string2' => 'arf12'); // foreach ($strings as $name => $testcase) { // if (ctype_cntrl($testcase)) { // echo "The string '$name' consists of all control characters.\n"; // } else { // echo "The string '$name' does not consist of all control characters.\n"; // } // } // [/php] // The above example will output: // [result] // The string 'string1' consists of all control characters. // The string 'string2' does not consist of all control characters. // [/result] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-22) // URL: https://www.php.net/manual/en/function.ctype-cntrl.php // ========== CTYPE_CNTRL - END // SYNTAX: // bool ctype_cntrl(mixed $text) return $return_ctype_cntrl; // bool } // ============================== END // PHP_VARIABLE_CTYPE_CTYPE_CNTRL // ============================== // ============================== BEGIN // PHP_VARIABLE_CTYPE_CTYPE_DIGIT // ============================== PUBLIC // ============================== ABOUT // Check for numeric character(s). // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // ctype_digit() - PHP_4 >= PHP_4_0_4, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_variable_ctype_ctype_digit($text) { $return_ctype_digit = false; // ========== CTYPE_DIGIT - BEGIN // ===== ABOUT // Check for numeric character(s) // ===== DESCRIPTION // Checks if all of the characters in the provided string, text, are numerical. // ===== SUPPORTED // PHP_4 >= PHP_4_0_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ctype_digit(mixed $text): bool // ===== CODE $return_ctype_digit = ctype_digit( $text // mixed text - The tested string. // Note: If an int between -128 and 255 inclusive is provided, it is interpreted as the ASCII value of a single character (negative values have 256 added in order to allow characters in the Extended ASCII range). Any other integer is interpreted as a string containing the decimal digits of the integer. // Warning: As of PHP 8.1.0, passing a non-string argument is deprecated. In the future, the argument will be interpreted as a string instead of an ASCII codepoint. Depending on the intended behavior, the argument should either be cast to string or an explicit call to chr() should be made. ); // Return Values // Returns true if every character in the string text is a decimal digit, false otherwise. When called with an empty string the result will always be false. // // [examples] // Examples // [example] // Example #1 A ctype_digit() example // [php] // $strings = array('1820.20', '10002', 'wsl!12'); // foreach ($strings as $testcase) { // if (ctype_digit($testcase)) { // echo "The string $testcase consists of all digits.\n"; // } else { // echo "The string $testcase does not consist of all digits.\n"; // } // } // [/php] // The above example will output: // [result] // The string 1820.20 does not consist of all digits. // The string 10002 consists of all digits. // The string wsl!12 does not consist of all digits. // [/result] // [/example] // [example] // Example #2 A ctype_digit() example comparing strings with integers // [php] // // $numeric_string = '42'; // $integer = 42; // // ctype_digit($numeric_string); // true // ctype_digit($integer); // false (ASCII 42 is the * character) // // is_numeric($numeric_string); // true // is_numeric($integer); // true // [/php] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-22) // URL: https://www.php.net/manual/en/function.ctype-digit.php // ========== CTYPE_DIGIT - END // SYNTAX: // bool ctype_digit(mixed $text) return $return_ctype_digit; // bool } // ============================== END // PHP_VARIABLE_CTYPE_CTYPE_DIGIT // ============================== // ============================== BEGIN // PHP_VARIABLE_CTYPE_CTYPE_GRAPH // ============================== PUBLIC // ============================== ABOUT // Check for any printable character(s) except space. // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // ctype_graph() - PHP_4 >= PHP_4_0_4, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_variable_ctype_ctype_graph($text) { $return_ctype_graph = false; // ========== CTYPE_GRAPH - BEGIN // ===== ABOUT // Check for any printable character(s) except space // ===== DESCRIPTION // Checks if all of the characters in the provided string, text, creates visible output. // ===== SUPPORTED // PHP_4 >= PHP_4_0_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ctype_graph(mixed $text): bool // ===== CODE $return_ctype_graph = ctype_graph( $text // mixed text - The tested string. // Note: If an int between -128 and 255 inclusive is provided, it is interpreted as the ASCII value of a single character (negative values have 256 added in order to allow characters in the Extended ASCII range). Any other integer is interpreted as a string containing the decimal digits of the integer. // Warning: As of PHP 8.1.0, passing a non-string argument is deprecated. In the future, the argument will be interpreted as a string instead of an ASCII codepoint. Depending on the intended behavior, the argument should either be cast to string or an explicit call to chr() should be made. ); // Return Values // Returns true if every character in text is printable and actually creates visible output (no white space), false otherwise. When called with an empty string the result will always be false. // // [examples] // Examples // [example] // Example #1 A ctype_graph() example // [php] // $strings = array('string1' => "asdf\n\r\t", 'string2' => 'arf12', 'string3' => 'LKA#@%.54'); // foreach ($strings as $name => $testcase) { // if (ctype_graph($testcase)) { // echo "The string '$name' consists of all (visibly) printable characters.\n"; // } else { // echo "The string '$name' does not consist of all (visibly) printable characters.\n"; // } // } // [/php] // The above example will output: // [result] // The string 'string1' does not consist of all (visibly) printable characters. // The string 'string2' consists of all (visibly) printable characters. // The string 'string3' consists of all (visibly) printable characters. // [/result] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-22) // URL: https://www.php.net/manual/en/function.ctype-graph.php // ========== CTYPE_GRAPH - END // SYNTAX: // bool ctype_graph(mixed $text) return $return_ctype_graph; // bool } // ============================== END // PHP_VARIABLE_CTYPE_CTYPE_GRAPH // ============================== // ============================== BEGIN // PHP_VARIABLE_CTYPE_CTYPE_LOWER // ============================== PUBLIC // ============================== ABOUT // Check for lowercase character(s). // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // ctype_lower() - PHP_4 >= PHP_4_0_4, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_variable_ctype_ctype_lower($text) { $return_ctype_lower = false; // ========== CTYPE_LOWER - BEGIN // ===== ABOUT // Check for lowercase character(s) // ===== DESCRIPTION // Checks if all of the characters in the provided string, text, are lowercase letters. // ===== SUPPORTED // PHP_4 >= PHP_4_0_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ctype_lower(mixed $text): bool // ===== CODE $return_ctype_lower = ctype_lower( $text // mixed text - The tested string. // Note: If an int between -128 and 255 inclusive is provided, it is interpreted as the ASCII value of a single character (negative values have 256 added in order to allow characters in the Extended ASCII range). Any other integer is interpreted as a string containing the decimal digits of the integer. // Warning: As of PHP 8.1.0, passing a non-string argument is deprecated. In the future, the argument will be interpreted as a string instead of an ASCII codepoint. Depending on the intended behavior, the argument should either be cast to string or an explicit call to chr() should be made. ); // Return Values // Returns true if every character in text is a lowercase letter in the current locale. When called with an empty string the result will always be false. // // [examples] // Examples // [example] // Example #1 A ctype_lower() example (using the default locale) // [php] // $strings = array('aac123', 'qiutoas', 'QASsdks'); // foreach ($strings as $testcase) { // if (ctype_lower($testcase)) { // echo "The string $testcase consists of all lowercase letters.\n"; // } else { // echo "The string $testcase does not consist of all lowercase letters.\n"; // } // } // [/php] // The above example will output: // [result] // The string aac123 does not consist of all lowercase letters. // The string qiutoas consists of all lowercase letters. // The string QASsdks does not consist of all lowercase letters. // [/result] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-22) // URL: https://www.php.net/manual/en/function.ctype-lower.php // ========== CTYPE_LOWER - END // SYNTAX: // bool ctype_lower(mixed $text) return $return_ctype_lower; // bool } // ============================== END // PHP_VARIABLE_CTYPE_CTYPE_LOWER // ============================== // ============================== BEGIN // PHP_VARIABLE_CTYPE_CTYPE_PRINT // ============================== PUBLIC // ============================== ABOUT // Check for printable character(s). // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // ctype_print() - PHP_4 >= PHP_4_0_4, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_variable_ctype_ctype_print($text) { $return_ctype_print = false; // ========== CTYPE_PRINT - BEGIN // ===== ABOUT // Check for printable character(s) // ===== DESCRIPTION // Checks if all of the characters in the provided string, text, are printable. // ===== SUPPORTED // PHP_4 >= PHP_4_0_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ctype_print(mixed $text): bool // ===== CODE $return_ctype_print = ctype_print( $text // mixed text - The tested string. // Note: If an int between -128 and 255 inclusive is provided, it is interpreted as the ASCII value of a single character (negative values have 256 added in order to allow characters in the Extended ASCII range). Any other integer is interpreted as a string containing the decimal digits of the integer. // Warning: As of PHP 8.1.0, passing a non-string argument is deprecated. In the future, the argument will be interpreted as a string instead of an ASCII codepoint. Depending on the intended behavior, the argument should either be cast to string or an explicit call to chr() should be made. ); // Return Values // Returns true if every character in text will actually create output (including blanks). Returns false if text contains control characters or characters that do not have any output or control function at all. When called with an empty string the result will always be false. // // [examples] // Examples // [example] // Example #1 A ctype_print() example // [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"; // } // } // [/php] // The above example will output: // [result] // 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. // [/result] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-22) // URL: https://www.php.net/manual/en/function.ctype-print.php // ========== CTYPE_PRINT - END // SYNTAX: // bool ctype_print(mixed $text) return $return_ctype_print; // bool } // ============================== END // PHP_VARIABLE_CTYPE_CTYPE_PRINT // ============================== // ============================== BEGIN // PHP_VARIABLE_CTYPE_CTYPE_PUNCT // ============================== PUBLIC // ============================== ABOUT // Check for any printable character which is not whitespace or an alphanumeric character. // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // ctype_punct() - PHP_4 >= PHP_4_0_4, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_variable_ctype_ctype_punct($text) { $return_ctype_punct = false; // ========== CTYPE_PUNCT - BEGIN // ===== ABOUT // Check for any printable character which is not whitespace or an alphanumeric character // ===== DESCRIPTION // Checks if all of the characters in the provided string, text, are punctuation character. // ===== SUPPORTED // PHP_4 >= PHP_4_0_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ctype_punct(mixed $text): bool // ===== CODE $return_ctype_punct = ctype_punct( $text // mixed text - The tested string. // Note: If an int between -128 and 255 inclusive is provided, it is interpreted as the ASCII value of a single character (negative values have 256 added in order to allow characters in the Extended ASCII range). Any other integer is interpreted as a string containing the decimal digits of the integer. // Warning: As of PHP 8.1.0, passing a non-string argument is deprecated. In the future, the argument will be interpreted as a string instead of an ASCII codepoint. Depending on the intended behavior, the argument should either be cast to string or an explicit call to chr() should be made. ); // Return Values // Returns true if every character in text is printable, but neither letter, digit or blank, false otherwise. When called with an empty string the result will always be false. // // [examples] // Examples // [example] // Example #1 A ctype_punct() example // [php] // $strings = array('ABasdk!@!$#', '!@ # $', '*&$()'); // foreach ($strings as $testcase) { // if (ctype_punct($testcase)) { // echo "The string $testcase consists of all punctuation.\n"; // } else { // echo "The string $testcase does not consist of all punctuation.\n"; // } // } // [/php] // The above example will output: // [result] // The string ABasdk!@!$# does not consist of all punctuation. // The string !@ # $ does not consist of all punctuation. // The string *&$() consists of all punctuation. // [/result] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-22) // URL: https://www.php.net/manual/en/function.ctype-punct.php // ========== CTYPE_PUNCT - END // SYNTAX: // bool ctype_punct(mixed $text) return $return_ctype_punct; // bool } // ============================== END // PHP_VARIABLE_CTYPE_CTYPE_PUNCT // ============================== // ============================== BEGIN // PHP_VARIABLE_CTYPE_CTYPE_SPACE // ============================== PUBLIC // ============================== ABOUT // Check for whitespace character(s). // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // ctype_space() - PHP_4 >= PHP_4_0_4, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_variable_ctype_ctype_space($text) { $return_ctype_space = false; // ========== CTYPE_SPACE - BEGIN // ===== ABOUT // Check for whitespace character(s) // ===== DESCRIPTION // Checks if all of the characters in the provided string, text, creates whitespace. // ===== SUPPORTED // PHP_4 >= PHP_4_0_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ctype_space(mixed $text): bool // ===== CODE $return_ctype_space = ctype_space( $text // mixed text - The tested string. // Note: If an int between -128 and 255 inclusive is provided, it is interpreted as the ASCII value of a single character (negative values have 256 added in order to allow characters in the Extended ASCII range). Any other integer is interpreted as a string containing the decimal digits of the integer. // Warning: As of PHP 8.1.0, passing a non-string argument is deprecated. In the future, the argument will be interpreted as a string instead of an ASCII codepoint. Depending on the intended behavior, the argument should either be cast to string or an explicit call to chr() should be made. ); // Return Values // Returns true if every character in text creates some sort of white space, false otherwise. Besides the blank character this also includes tab, vertical tab, line feed, carriage return and form feed characters. When called with an empty string the result will always be false. // // [examples] // Examples // [example] // Example #1 A ctype_space() example // [php] // $strings = array( // 'string1' => "\n\r\t", // 'string2' => "\narf12", // 'string3' => '\n\r\t' // note the single quotes // ); // foreach ($strings as $name => $testcase) { // if (ctype_space($testcase)) { // echo "The string '$name' consists of whitespace characters only.\n"; // } else { // echo "The string '$name' contains non-whitespace characters.\n"; // } // } // [/php] // The above example will output: // [result] // The string 'string1' consists of whitespace characters only. // The string 'string2' contains non-whitespace characters. // The string 'string3' contains non-whitespace characters. // [/result] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-22) // URL: https://www.php.net/manual/en/function.ctype-space.php // ========== CTYPE_SPACE - END // SYNTAX: // bool ctype_space(mixed $text) return $return_ctype_space; // bool } // ============================== END // PHP_VARIABLE_CTYPE_CTYPE_SPACE // ============================== // ============================== BEGIN // PHP_VARIABLE_CTYPE_CTYPE_UPPER // ============================== PUBLIC // ============================== ABOUT // Check for uppercase character(s). // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // ctype_upper() - PHP_4 >= PHP_4_0_4, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_variable_ctype_ctype_upper($text) { $return_ctype_upper = false; // ========== CTYPE_UPPER - BEGIN // ===== ABOUT // Check for uppercase character(s) // ===== DESCRIPTION // Checks if all of the characters in the provided string, text, are uppercase characters. // ===== SUPPORTED // PHP_4 >= PHP_4_0_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ctype_upper(mixed $text): bool // ===== CODE $return_ctype_upper = ctype_upper( $text // mixed text - The tested string. // Note: If an int between -128 and 255 inclusive is provided, it is interpreted as the ASCII value of a single character (negative values have 256 added in order to allow characters in the Extended ASCII range). Any other integer is interpreted as a string containing the decimal digits of the integer. // Warning: As of PHP 8.1.0, passing a non-string argument is deprecated. In the future, the argument will be interpreted as a string instead of an ASCII codepoint. Depending on the intended behavior, the argument should either be cast to string or an explicit call to chr() should be made. ); // Return Values // Returns true if every character in text is an uppercase letter in the current locale. When called with an empty string the result will always be false. // // [examples] // Examples // [example] // Example #1 A ctype_upper() example (using the default locale) // [php] // $strings = array('AKLWC139', 'LMNSDO', 'akwSKWsm'); // foreach ($strings as $testcase) { // if (ctype_upper($testcase)) { // echo "The string $testcase consists of all uppercase letters.\n"; // } else { // echo "The string $testcase does not consist of all uppercase letters.\n"; // } // } // [/php] // The above example will output: // [result] // The string AKLWC139 does not consist of all uppercase letters. // The string LMNSDO consists of all uppercase letters. // The string akwSKWsm does not consist of all uppercase letters. // [/result] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-22) // URL: https://www.php.net/manual/en/function.ctype-upper.php // ========== CTYPE_UPPER - END // SYNTAX: // bool ctype_upper(mixed $text) return $return_ctype_upper; // bool } // ============================== END // PHP_VARIABLE_CTYPE_CTYPE_UPPER // ============================== // ============================== BEGIN // PHP_VARIABLE_CTYPE_CTYPE_XDIGIT // ============================== PUBLIC // ============================== ABOUT // Check for character(s) representing a hexadecimal digit. // ============================== SUPPORT // PHP_4 - PHP_8 // ============================== USING FUNCTIONS (1) // ctype_xdigit() - PHP_4 >= PHP_4_0_4, PHP_5, PHP_7, PHP_8 // ============================== CODE function php_variable_ctype_ctype_xdigit($text) { $return_ctype_xdigit = false; // ========== CTYPE_XDIGIT - BEGIN // ===== ABOUT // Check for character(s) representing a hexadecimal digit // ===== DESCRIPTION // Checks if all of the characters in the provided string, text, are hexadecimal 'digits'. // ===== SUPPORTED // PHP_4 >= PHP_4_0_4, PHP_5, PHP_7, PHP_8 // ===== SYNTAX // ctype_xdigit(mixed $text): bool // ===== CODE $return_ctype_xdigit = ctype_xdigit( $text // mixed text - The tested string. // Note: If an int between -128 and 255 inclusive is provided, it is interpreted as the ASCII value of a single character (negative values have 256 added in order to allow characters in the Extended ASCII range). Any other integer is interpreted as a string containing the decimal digits of the integer. // Warning: As of PHP 8.1.0, passing a non-string argument is deprecated. In the future, the argument will be interpreted as a string instead of an ASCII codepoint. Depending on the intended behavior, the argument should either be cast to string or an explicit call to chr() should be made. ); // Return Values // Returns true if every character in text is a hexadecimal 'digit', that is a decimal digit or a character from [A-Fa-f] , false otherwise. When called with an empty string the result will always be false. // // [examples] // Examples // [example] // Example #1 A ctype_xdigit() example // [php] // $strings = array('AB10BC99', 'AR1012', 'ab12bc99'); // foreach ($strings as $testcase) { // if (ctype_xdigit($testcase)) { // echo "The string $testcase consists of all hexadecimal digits.\n"; // } else { // echo "The string $testcase does not consist of all hexadecimal digits.\n"; // } // } // [/php] // The above example will output: // [result] // The string AB10BC99 consists of all hexadecimal digits. // The string AR1012 does not consist of all hexadecimal digits. // The string ab12bc99 consists of all hexadecimal digits. // [/result] // [/example] // [/examples] // ===== LITERATURE_SOURCES // * PHP_NET (2024-01-22) // URL: https://www.php.net/manual/en/function.ctype-xdigit.php // ========== CTYPE_XDIGIT - END // SYNTAX: // bool ctype_xdigit(mixed $text) return $return_ctype_xdigit; // bool } // ============================== END // PHP_VARIABLE_CTYPE_CTYPE_XDIGIT // ============================== // ============================== END // PHP_VARIABLE_CTYPE // ============================== ?>