Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/252.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 - Fatal编程技术网

PHP一致性问题,没有与代码相关的错误,但也没有预期的输出

PHP一致性问题,没有与代码相关的错误,但也没有预期的输出,php,Php,通过本文的上下文,您可能会注意到,我是一名学习php的初学者。我已经注意到,我面临着一个有趣但令人沮丧的问题。我始终没有代码错误,但我的预期输出并不总是在页面上回响或显示。这是我在使用PHP时需要注意的问题,还是新手看到了这个奇怪的问题。我必须不断地回溯代码,看看我的错误是什么,但没有错误。提前谢谢 ---------职能---------- ---------配置文件php文件------- $file_name = $_FILE['profile']['name'];

通过本文的上下文,您可能会注意到,我是一名学习php的初学者。我已经注意到,我面临着一个有趣但令人沮丧的问题。我始终没有代码错误,但我的预期输出并不总是在页面上回响或显示。这是我在使用PHP时需要注意的问题,还是新手看到了这个奇怪的问题。我必须不断地回溯代码,看看我的错误是什么,但没有错误。提前谢谢

---------职能----------

---------配置文件php文件-------
      $file_name = $_FILE['profile']['name'];
      $file_extn = strtolower(end(explode('.', $file_name)));
      $file_temp = $_FILE['profile']['tmp_name'];

      if(in_array($file_extn, $allowed) === true){
         change_profile_image($session_user_id, $file_temp, $file_extn);
         header('Location:' .$current_file);
         exit();
      }else{
          $errors[] = 'Incorrect file type. Allow: ';
          echo implode(', ', $allowed);
      }
    }
  }
  if(empty($user_data['profile']) === false){
     echo '<image src="', $user_data['profile'],'" alt="', $user_data['first_name'], '\'s Profile Image">';
   }
   ?>
    <form action="" method="post" enctype="multipart/form-data">
        <input type="file" name="profile"> <input type="submit">
    </form>
$file\u name=$\u file['profile']['name'];
$file_extn=strtolower(end(explode('.',$file_name));
$file\u temp=$\u file['profile']['tmp\u name'];
if(在数组中($file\u extn,$allowed)==true){
更改配置文件映像($session\u user\u id、$file\u temp、$file\u extn);
标题('位置:'.$当前_文件);
退出();
}否则{
$errors[]=“文件类型不正确。允许:”;
回波内爆(',',$允许);
}
}
}
if(空($user_data['profile'])==false){
回声';
}
?>

尝试打开错误报告。 让php显示所有错误

error_reporting(E_ALL);
ini_set('display_errors', '1');
在php文件的开头使用此代码段


或者,您可以检查服务器日志,看看是否出现了问题。

我终于发现了代码的问题。我有一个语法错误,我应该有$u文件,而不是$文件。我在整个过程中都漏掉了一个“S”或者一堆“S”

从您提供的代码判断,我认为问题在于您忘记了编写PHP脚本…:)。目前,我正在处理一个教程,显示如何上传一个文件到“个人资料”页面,但我没有得到图像上传,我没有得到任何错误。我可以显示代码。嗨,卢西恩,谢谢你指出这一点。我试着把建议的代码放在我的文件顶部,并在上传过程中再次检查它,但没有效果。干杯好的,如果问题仍然存在,请检查服务器日志,查看运行代码时服务器上发生的情况。是否有方法模拟代码在我的本地主机和实时服务器上100%的行为。我想这可能是我的问题。尽管如此,如果在localhost上没有得到预期的任何输出,我会不断地将新的更改传输到服务器并进行测试。我检查了服务器上我的根目录下的logs文件夹,它对我来说都是“中文”的。我为没有更好的词而道歉。
error_reporting(E_ALL);
ini_set('display_errors', '1');