php5.2.17下程式碼運作正常,
php5.4以上就報錯。
原始碼如下:
入口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));
= 1;
$ret[] = $result;
}catch (Exception $e){
************* ***
}
return $result;
}
service.inc.php文件#service.inc.php文件
#<?php
if (isset($GLOBALS[' includefiles'.__FILE__])){
return;
}else{
# $GLOBALS['includefiles'.__FILE__ __autoload($class_name) {
//判斷檔案是否存在
if(strpos($class_name,"Service")!==false){
# WG_SERVER_BASE. 'service/'.$class_name.'.php'; }else if(strpos($class_name,"API")!==false){# . 'api/'.PLATFORM_TYPE."/".$class_name.'.php';}else if(strpos($class_name,"Data")!==false){
$fileUrl = WG_SERVER_BASE. 'data/'. ## }else{
$fileUrl = WG_SERVER_BASE.$class_name.'.php';
}
#o> ){ require $fileUrl;# } } date_default_timezone_set('Etc/GMT-8');# ##.PH環境5.4以上報錯,5.2卻正常,求教如何相容PHP5.2--5.6環境而不出錯? ? ? ,錯誤代碼:
Strict standards: Non-static method Command::call() should not be called statically in ***/Gateway.php on line 13
#Strict standards: call_user_func_array() expects parameter 1 to be a valid callback, non-static method ******** should not be called statically in ***********
#Warning: Cannot modify header information - headers already sent by (output started at **********Command.php:62) in *************\Gateway.php on line 16