⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 json.php

📁 很棒的在线教学系统
💻 PHP
字号:
<?phprequire_once 'HTML/AJAX/JSON.php';// $Id: JSON.php,v 1.1.2.1 2008/10/03 07:09:49 nicolasconnault Exp $/** * JSON Serializer * * @category   HTML * @package    AJAX * @author     Joshua Eichorn <josh@bluga.net> * @copyright  2005 Joshua Eichorn * @license    http://www.opensource.org/licenses/lgpl-license.php  LGPL * @version    Release: 0.5.6 * @link       http://pear.php.net/package/PackageName */// {{{ class HTMLA_AJAX_Serialize_JSONclass HTML_AJAX_Serializer_JSON {    // {{{ variables-properties    /**     * JSON instance     * @var HTML_AJAX_JSON     * @access private     */    var $_json;    /**     * use json php extension http://www.aurore.net/projects/php-json/     * @access private     */    var $_jsonext;    /**     * use loose typing to decode js objects into php associative arrays     * @access public     */    var $loose_type;        // }}}    // {{{ constructor    function HTML_AJAX_Serializer_JSON($use_loose_type = true)     {        $this->loose_type = (bool) $use_loose_type;        $this->_jsonext = $this->_detect();        if(!$this->_jsonext) {            $use_loose_type = ($this->loose_type) ? SERVICES_JSON_LOOSE_TYPE : 0;            $this->_json = new HTML_AJAX_JSON($use_loose_type);        }    }    // }}}    // {{{ serialize    /**     * This function serializes and input passed to it.     *     * @access public     * @param  string $input   The input to serialize.     * @return string $input   The serialized input.     */    function serialize($input)     {        if($this->_jsonext) {            return json_encode($input);        } else {            return $this->_json->encode($input);        }    }    // }}}    // {{{ unserialize    /**     * this function unserializes the input passed to it.     *     * @access public     * @param  string $input   The input to unserialize     * @return string $input   The unserialized input.     */    function unserialize($input)     {        if($this->_jsonext) {            return json_decode($input, $this->loose_type);        } else {            return $this->_json->decode($input);        }    }    // }}}    // {{{ _detect    /**     * detects the loaded extension     */    function _detect()    {        return extension_loaded('json');    }    // }}}}// }}}/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -