Release 2015-08-10 "Detritus"
[dokuwiki.git] / inc / compatibility.php
blobcb865a2d71f8e84c710bab21bcac84408219bf46
1 <?php
2 /**
3 * compatibility functions
5 * This file contains a few functions that might be missing from the PHP build
6 */
8 if(!function_exists('ctype_space')) {
9 /**
10 * Check for whitespace character(s)
12 * @see ctype_space
13 * @param string $text
14 * @return bool
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;
23 if(!function_exists('ctype_digit')) {
24 /**
25 * Check for numeric character(s)
27 * @see ctype_digit
28 * @param string $text
29 * @return bool
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;
38 if(!function_exists('gzopen') && function_exists('gzopen64')) {
39 /**
40 * work around for PHP compiled against certain zlib versions #865
42 * @link http://stackoverflow.com/questions/23417519/php-zlib-gzopen-not-exists
44 * @param string $filename
45 * @param string $mode
46 * @param int $use_include_path
47 * @return mixed
49 function gzopen($filename, $mode, $use_include_path = 0) {
50 return gzopen64($filename, $mode, $use_include_path);
54 if(!function_exists('gzseek') && function_exists('gzseek64')) {
55 /**
56 * work around for PHP compiled against certain zlib versions #865
58 * @link http://stackoverflow.com/questions/23417519/php-zlib-gzopen-not-exists
60 * @param resource $zp
61 * @param int $offset
62 * @param int $whence
63 * @return int
65 function gzseek($zp, $offset, $whence = SEEK_SET) {
66 return gzseek64($zp, $offset, $whence);
70 if(!function_exists('gztell') && function_exists('gztell64')) {
71 /**
72 * work around for PHP compiled against certain zlib versions #865
74 * @link http://stackoverflow.com/questions/23417519/php-zlib-gzopen-not-exists
76 * @param resource $zp
77 * @return int
79 function gztell($zp) {
80 return gztell64($zp);