functions-compat.php shall hold PHP functions needed for PHP 4.1 compatibility
git-svn-id: https://develop.svn.wordpress.org/trunk@1776 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
24359ab0fb
commit
370d9aee36
50
wp-includes/functions-compat.php
Normal file
50
wp-includes/functions-compat.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
/* Functions missing from older PHP versions */
|
||||
|
||||
|
||||
/* Added in PHP 4.2.0 */
|
||||
|
||||
if (!function_exists('floatval')) {
|
||||
function floatval($string) {
|
||||
return ((float) $string);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('is_a')) {
|
||||
function is_a($object, $class) {
|
||||
// by Aidan Lister <aidan@php.net>
|
||||
if (get_class($object) == strtolower($class)) {
|
||||
return true;
|
||||
} else {
|
||||
return is_subclass_of($object, $class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('ob_clean')) {
|
||||
function ob_clean() {
|
||||
// by Aidan Lister <aidan@php.net>
|
||||
if (@ob_end_clean()) {
|
||||
return ob_start();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Added in PHP 4.3.0 */
|
||||
|
||||
function printr($var, $do_not_echo = false) {
|
||||
// from php.net/print_r user contributed notes
|
||||
ob_start();
|
||||
print_r($var);
|
||||
$code = htmlentities(ob_get_contents());
|
||||
ob_clean();
|
||||
if (!$do_not_echo) {
|
||||
echo "<pre>$code</pre>";
|
||||
}
|
||||
return $code;
|
||||
}
|
||||
|
||||
?>
|
Loading…
Reference in New Issue
Block a user