在尝试从服务器访问PHP文件时获取PHP致命错误:require()

时间:2016-12-12 14:43:32

标签: php android

我无法从android端或谷歌浏览器访问我的php文件,我在error_log文件中收到以下错误:

[12-Dec-2016 13:41:53 UTC] PHP Warning:  require(./Classes/Classes.php): failed to open stream: No such file or directory in /home/shaye/public_html/social/index.php on line 12
[12-Dec-2016 13:41:53 UTC] PHP Warning:  require(./Classes/Classes.php): failed to open stream: No such file or directory in /home/shaye/public_html/social/index.php on line 12
[12-Dec-2016 13:41:53 UTC] PHP Fatal error:  require(): Failed opening required './Classes/Classes.php' (include_path='.:/opt/cpanel/ea-php56/root/usr/share/pear') in /home/shaye/public_html/social/index.php on line 12

这也是我的index.php文件:

     <?php ob_start(); header("charset=utf-8;");
 $dir = str_replace("index.php","",$_SERVER['PHP_SELF']);

 $params = str_replace($dir,"",$_SERVER['REQUEST_URI']);

 $params = trim($params,"/");

 $params = explode("/",$params);

 if(isset($params[0]) && isset($params[1]))
 {
 require './Classes/'.basename($params[0]).".php";
 $class = new $params[0]();
 $class->$params[1]();
 }
 else
 {
 exit;
 }

 ?>

这是我在服务器中的PHP文件的地址:

shayea.tk/social/Classes/

我在android端使用MultipartUtility库 请帮助我不太了解PHP

1 个答案:

答案 0 :(得分:0)

再次检查以下行

require './Classes/'.basename($params[0]).".php";

我认为路径不匹配,可能如下所示,或者给出正确的目录路径。

require '../Classes/'.basename($params[0]).".php";