php5.2.17下代碼運(yùn)行正常,
php5.4以上就報(bào)錯(cuò)。
源碼如下:
入口Gateway.php文檔:
<?php require dirname(__FILE__) . '/Command.php';
$d=$_POST['data'];
if(get_magic_quotes_gpc()){
$d=stripslashes($d);
}
$param = json_decode($d);
$ret = Command::call($param);
header('content-type:application:json;charset=utf8');
header('Access-Control-Allow-Origin:*');
header('Access-Control-Allow-Methods:POST');
header('Access-Control-Allow-Headers:x-requested-with,content-type');
echo json_encode($ret);
?>
Commadn.php文檔:
<?php
require dirname(__FILE__) . '/service.inc.php';
class Command{
????pulibic function call($params){
????????$result = self::callMethod(*********);
????????return $result;
????}
private function callMethod(***){
try {
???? if(count($params)>0){
???? $result=call_user_func_array(Array($classStr,$funcStr),$params);
???? }else{
???? $result=call_user_func(Array($classStr,$funcStr));
???? } ? ? ??
???? $ret[] = 1;
???? $ret[] = $result; ??
???? }catch (Exception $e){
????????****************
????}
????return $result;
}
service.inc.php文檔
<?php
define("WG_SERVER_BASE",dirname(__FILE__) . "/");
if (isset($GLOBALS['includefiles'.__FILE__])){
????return;
}else{
???? $GLOBALS['includefiles'.__FILE__]=true;
???? function __autoload($class_name) {
???? //判斷文件是否存在
???? if(strpos($class_name,"Service")!==false){
???????? $fileUrl = WG_SERVER_BASE. 'service/'.$class_name.'.php';
???????? }else if(strpos($class_name,"API")!==false){
???????? $fileUrl = WG_SERVER_BASE. 'api/'.PLATFORM_TYPE."/".$class_name.'.php';
???????? }else if(strpos($class_name,"Data")!==false){
???????? $fileUrl = WG_SERVER_BASE. 'data/'.$class_name.'.php';
???? }else{
???? ???? $fileUrl = WG_SERVER_BASE.$class_name.'.php';
???? }
???? if(file_exists($fileUrl)){
???? ? require $fileUrl;
???? }
}
date_default_timezone_set ('等/GMT-8');?
}
##PH環(huán)境5.4以上報(bào)錯(cuò),5.2卻正常,求教如何兼容PHP5.2--5.6環(huán)境而不出錯(cuò)???,錯(cuò)誤代碼:
嚴(yán)格標(biāo)準(zhǔn):非靜態(tài)方法Command::call() 不應(yīng)在中靜態(tài)調(diào)用 ***/Gateway.php 第 13 行
##嚴(yán)格標(biāo)準(zhǔn):call_user_func_array() 需要 參數(shù)1是一個(gè)有效的回調(diào),非靜態(tài)方法 ******** 不應(yīng)在 ****************
問題補(bǔ)充:如果無(wú)法兼容5.2--5.6,那請(qǐng)教如何將上面的可以在5.2環(huán)境下正常運(yùn)行的代碼改造成5.4以上可執(zhí)行?