- <?php
- if (! function_exists ( 'json_decode' )) {
- /**
- * Decodes a JSON string
- *
- * @param string $content The jsonstring being decoded.
- * @param bool $assoc When true, returned objects will be converted into associative arrays.
- * @return mixed Returns an object or if the optional assoc parameter is true, an associative array is instead returned.
- *
- */
- function json_decode($content, $assoc = false) {
- require_once '../Lib/Json/JSON.php';
- if ($assoc) {
- $json = new Services_JSON ( SERVICES_JSON_LOOSE_TYPE );
- } else {
- $json = new Services_JSON ( );
- }
- return $json->decode ( $content );
- }
- }
- if (! function_exists ( 'json_encode' )) {
- /**
- * Returns the JSON representation of a value
- *
- * @param mixed $content The value being encoded. Can be any type except a resource. This function only works with UTF-8 encoded data.
- * @return string Returns a JSON encoded string on success.
- *
- */
- function json_encode($content) {
- require_once '../Lib/Json/JSON.php';
- $json = new Services_JSON ( );
- return $json->encode ( $content );
- }
- }
- if (! function_exists ( 'property_exists' )) {
- /**
- * Checks if the object or class has a property
- *
- * @param mixed $class he class name or an object of the class to test for
- * @param string $property The name of the property
- * @return bool Returns true if the property exists, false if it doesn't exist or null in case of an error.
- *
- */
- function property_exists($class, $property) {
- if (is_object ( $class )) {
- $vars = get_object_vars ( $class );
- } else {
- $vars = get_class_vars ( $class );
- }
- return array_key_exists ( $property, $vars );
- }
- }
- if (! function_exists ( 'stripslashes_deep' )) {
- /**
- * Un-quote string quoted with addslashes
- *
- * @param string $value The input string
- * @return string Returns a string with backslashes stripped off. (/' becomes ' and so on.) Double backslashes (//) are made into a single backslash (/).
- *
- */
- function stripslashes_deep($value) {
- $value = is_array ( $value ) ? array_map ( 'stripslashes_deep', $value ) : stripslashes ( $value );
- return $value;
- }
- }
- ?>
PHP几个函数兼容
最新推荐文章于 2025-04-16 01:24:25 发布