Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/282.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php脚本错误调试_Php_Debugging - Fatal编程技术网

php脚本错误调试

php脚本错误调试,php,debugging,Php,Debugging,我有一个问题,一个简单的php编码错误,我无法找出错误的确切位置,有没有办法调试php脚本 <?php $fnC = "./includes/dbConnect.php" ; if(file_exists($fnC) ) { require_once($fnC); echo "$fnC is found" ; } else { echo "file does not exist : $fn

我有一个问题,一个简单的php编码错误,我无法找出错误的确切位置,有没有办法调试php脚本

<?php  
    $fnC = "./includes/dbConnect.php" ;   
    if(file_exists($fnC) )  {
      require_once($fnC); 
      echo "$fnC is found" ; 
    }  
    else
    { 
        echo "file does not exist : $fnC" ;  
    } 
?>
<?php  
    $fnF = "./includes/dbFunctions.php" ; 
    if(file_exists($fnF) )  {
      require_once($fnF); 
      echo "$fnF is found" ;
    }  
    else {
        echo "file does not exist : $fnF" ;  
    } 
?>

<?php
    foreach($_POST as $key => $i){
            print("$key=$i<br>");
    }


echo "script finish";
?>

有没有线索表明错误在哪里? 这两个文件存在于includes/中,得到了dbConnect.php的第一个回音(文件存在),然后什么都没有 ,脚本停止
谢谢。

要检查php中的错误,请使用php错误报告:

error_reporting(-1);
ini_set('display_errors', 'On');
您可以将该代码放在php代码的顶部


这将打印出php代码中的任何错误。

有时,您需要维护包含顺序! 当包含的文件需要一些资源(如类定义、函数体等)时,应该首先包含包含这些资源的文件

但是,如果您在单个文件中编写整个内容,则不需要这样做

如果您得到“无法打开流”,尽管您确信您的include\u路径正确,请检查您的
打开\u basedir
设置。因此,为了避免任何奇怪的问题和痛苦的调试,请确保系统中使用的所有路径在任何地方都具有相同的情况,并且它们与文件系统的实际情况相对应。这包括在webserver
config/php.ini
中设置的包含路径、自动加载配置、运行时包含路径设置或其他任何位置


这可能仅仅是因为您包含的目录不在
open\u basedir
的范围内,这会阻止php访问根目录之外的文件(通常)。

检查
错误日志。
。感谢您的及时回答,我现在就要测试了,很高兴它能帮上忙。)