更新2:
我现在已从.php文件中删除以下内容:
<?php error_reporting( E_ALL ); ?>
Run Code Online (Sandbox Code Playgroud)
我在php.ini中设置了display_erros,如下所示:
display_errors = On
错误报告在php.ini中设置为以下内容
error_reporting = E_ALL | E_STRICT
重启apache后,我仍然没有错误/警告.
更新1:
我在php.ini中更改了error_reporting:
error_reporting = E_ALL&~E_DEPRECATED
至
error_reporting = E_ALL | E_STRICT
之后我重新启动了apache,例如
/etc/init.d/apache2 restart
但页面仍然不会显示任何类型的错误/警告.
原始问题:
以下脚本正在生成警告,因为$ err位于if语句中.为什么这个警告没有显示在Web浏览器的PHP页面上?我必须查看apache日志才能看到警告.另外,如果我故意将"insert into"更改为"delete into",它不会在PHP页面上显示错误.为什么错误不显示在实际的PHP页面上?
<?php
error_reporting(E_ALL);
?>
<html>
<head>
<title></title>
<link rel="icon" type="image/png" href="favicon.ico">
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$err = array();
if (empty( $_POST['display_name']))
$err[] = "display name field is required";
if (empty( $_POST['email']))
$err[] = "email field is required";
if (empty( $_POST['password']))
$err[] …Run Code Online (Sandbox Code Playgroud) 我在共享主机上有Cpanel,Apache,PHP由fastcgi运行.PHP存储错误日志在哪里?
有没有其他方法可以在共享主机环境中找到错误日志,而不必通过整个站点结构来查找error_log文件?
我可以访问php.ini(我使用的是PHP版本5.2.16).
我的网站只有4-5个静态页面.index.html和index.php都在那里.index.html工作正常.如果我改为index.php,那就是给予500 Internal Server Error.我不知道我的错误在哪里?
注意:
如果我使用.htaccess文件php_flag display_errors 1,
它正在显示 Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
如果我使用.htaccess文件empty,
它正在显示 Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
如果我给../contact-us.php,它显示正确.
谢谢...
我有运行的Apache2和PHP 5.在我设置php.ini中Ubuntu的服务器error_reporting = E_ALL | E_STRICT和error_reporting = E_ALL | E_STRICT,但是PHP仍然没有显示错误消息.我也在使用Apache虚拟主机.
另外,PHP5.3提供的最严格的错误报告是什么?我希望我的代码尽可能地保持最新和面向未来.
我安装了XAMPP 1.7.4(用PHP 5.3.5),问题是PHP没有显示任何错误信息.例如,如果我连接到mysql_connect()没有参数的MYSQL ,PHP将不会抱怨所需的字段.
为什么是这样?
如何配置PHP以显示错误?
隐藏所有 php错误的最佳做法是什么?因为我不希望错误显示给用户.
我已经尝试过.htacess将代码php_flag display_errors off放在那里,但它会给我一个回复500 error.
有没有其他方法可以隐藏所有错误?
我正在使用PHP-FPM运行nginx.我处理php文件的nginx配置如下所示:
location ~ \.php$ {
set $php_root /home/me/www;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $php_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
Run Code Online (Sandbox Code Playgroud)
现在,我有一个简单的php文件,如下所示:
<?php
ech "asd"
asd""
?>
Run Code Online (Sandbox Code Playgroud)
是的,有一个明显的错误.当我尝试访问php文件,而不是跟踪语法错误时,我总是得到HTTP 500内部服务器错误.我尝试使用error_reporting(-1);但仍然总是返回HTTP 500.如何让PHP打印确切的错误而不是返回通用HTTP 500?
我已经在Amazon AWS上使用*Apache2/MySQL/PHP5安装了全新的Ubuntu Server 12.04 LTS.当我运行PHP脚本并遇到错误时,我没有看到PHP的任何错误报告,我所看到的就是
HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfil the request.
Run Code Online (Sandbox Code Playgroud)
我已经检查了我的/etc/php5/apache2/php.ini文件,据我所知,应该设置错误报告.文件的内容(关于错误)是:
; display_errors
; Default Value: On
; Development Value: On
; Production Value: Off
; display_startup_errors
; Default Value: Off
; Development Value: On
; Production Value: Off
; error_reporting
; Default Value: E_ALL & ~E_NOTICE
; Development Value: E_ALL | E_STRICT
; Production Value: E_ALL & ~E_DEPRECATED
Run Code Online (Sandbox Code Playgroud)
任何人都可以建议吗?如果我尝试类似的东西$obj = new …
PHP会强制显示错误的原因是什么,无论你告诉它禁用什么?
我试过了
error_reporting(0);
ini_set('display_errors', 0);
Run Code Online (Sandbox Code Playgroud)
没有运气.
莫名其妙!
我有一个应该存储一些会话的页面,但是当我尝试打印时,没有任何内容显示出来.
那里必须有会话,因为第一页有一个链接,带我到第二页,在第二页我可以成功显示会话!
<?
session_start();
include "frontend/header.php";
?>
</head>
<body>
<div id="header">
<? include "frontend/menu.php";?>
<div class="clear"></div>
</div>
<div id="green_bg" style="display:block">
<?
echo "1";
echo "<pre>";print_r($_SESSION); echo"</pre>";
?>
<div class="main thank-you">
<a class="thank_you">Thank You</a>
<p>Your phone number will be refilled in a moment. <br/>
Please check your emails for confirmation.
</p>
<div class="signUp4MonthlyRefills" style="background-color: #f7931e; padding: 20px;">
<h3>Do you want to save time and effort?</h3>
<br/>
Then leave the refills to us!!
<br/>
<br/><i>Introducing</i>... Auto Monthly Refills!!
<p>Sign up for …Run Code Online (Sandbox Code Playgroud)