[PHP] JSON PHP 5.2.0以前的支援

by Mesak
if(!function_exists('json_decode')){
include("json.php");
$json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
function json_decode($arr){
global $json;
return $json->decode($arr);
}
function json_encode($arr){
global $json;
return $json->encodeUnsafe($arr);
}
}

JSON Class 的名稱為 Services_JSON

* @category
* @package     Services_JSON
* @author &nbsp; &nbsp; &nbsp;Michal Migurski <[email protected]>
* @author &nbsp; &nbsp; &nbsp;Matt Knapp <mdknapp[at]gmail[dot]com>
* @author &nbsp; &nbsp; &nbsp;Brett Stimmerman <brettstimmerman[at]gmail[dot]com>
* @copyright &nbsp; 2005 Michal Migurski
* @version &nbsp; &nbsp; CVS: $Id: JSON.php,v 1.31 2006/06/28 05:54:17 migurski Exp $
* @license &nbsp; &nbsp; http://www.opensource.org/licenses/bsd-license.php
* @link &nbsp; &nbsp; &nbsp; &nbsp;http://pear.php.net/pepr/pepr-proposal-show.php?id=198

這樣在一堆有的沒的的地方就可以 用 JSON 儲存 繁複的資訊

也可以跟 Javascript 做資訊的傳遞, 非常適合AJAX 類的網頁使用

You may also like