xref: /dokuwiki/inc/compatibility.php (revision fc4ff0c349240d12ff91559183e1103ad2c5fa91)
1<?php
2/**
3 * compatibility functions
4 *
5 * This file contains a few functions that might be missing from the PHP build
6 */
7
8if(!function_exists('ctype_space')) {
9    /**
10     * Check for whitespace character(s)
11     *
12     * @see ctype_space
13     * @param string $text
14     * @return bool
15     */
16    function ctype_space($text) {
17        if(!is_string($text)) return false; #FIXME original treats between -128 and 255 inclusive as ASCII chars
18        if(trim($text) === '') return true;
19        return false;
20    }
21}
22
23if(!function_exists('ctype_digit')) {
24    /**
25     * Check for numeric character(s)
26     *
27     * @see ctype_digit
28     * @param string $text
29     * @return bool
30     */
31    function ctype_digit($text) {
32        if(!is_string($text)) return false; #FIXME original treats between -128 and 255 inclusive as ASCII chars
33        if(preg_match('/^\d+$/', $text)) return true;
34        return false;
35    }
36}