我正在使用Codeigniter,而不是错误消息,我只是得到一个空白页面.有没有办法显示PHP错误消息?当我得不到任何反馈时,很难调试.
我的环境是使用Apache的Ubuntu.
Wes*_*rch 93
由于到目前为止,似乎没有一个解决方案适合您,请尝试以下方法:
ini_set('display_errors', 1);
Run Code Online (Sandbox Code Playgroud)
http://www.php.net/manual/en/errorfunc.configuration.php#ini.display-errors
这明确告诉PHP 显示错误.某些环境可以默认禁用此功能.
这就是我的环境设置index.php
:
/*
*---------------------------------------------------------------
* APPLICATION ENVIRONMENT
*---------------------------------------------------------------
*/
define('ENVIRONMENT', 'development');
/*
*---------------------------------------------------------------
* ERROR REPORTING
*---------------------------------------------------------------
*/
if (defined('ENVIRONMENT'))
{
switch (ENVIRONMENT)
{
case 'development':
// Report all errors
error_reporting(E_ALL);
// Display errors in output
ini_set('display_errors', 1);
break;
case 'testing':
case 'production':
// Report all errors except E_NOTICE
// This is the default value set in php.ini
error_reporting(E_ALL ^ E_NOTICE);
// Don't display errors (they can still be logged)
ini_set('display_errors', 0);
break;
default:
exit('The application environment is not set correctly.');
}
}
Run Code Online (Sandbox Code Playgroud)
ale*_*n13 30
确保php5-mysql
已安装.
我有同样的问题,正如Shayan Husaini指出的那样,我有一个未检测到的语法错误.
我使用终端中的php linter解决了它:
php -l file.php
Run Code Online (Sandbox Code Playgroud)
您也可以使用类似的东西在某个文件夹中的每个文件中使用linter:
find -type f -name "*.php" -exec php -l '{}' \;
Run Code Online (Sandbox Code Playgroud)
并过滤只有错误的那些:
find -type f -name "*.php" -exec php -l '{}' \; | grep '^[^N]'
Run Code Online (Sandbox Code Playgroud)
这应该显示具有解析错误的文件和错误所在的行.
当您的代码中有基本的PHP语法错误时会出现此问题.如果你有语法错误,php解析器不完全解析代码并且没有显示任何内容,因此只有当你有语法错误以外时,所有上述建议才会起作用.
你可以在主index.php中设置它
define('ENVIRONMENT', 'development');
/*
*---------------------------------------------------------------
* ERROR REPORTING
*---------------------------------------------------------------
*
* Different environments will require different levels of error reporting.
* By default development will show errors but testing and live will hide them.
*/
if (defined('ENVIRONMENT'))
{
switch (ENVIRONMENT)
{
case 'development':
error_reporting(E_ALL);
break;
case 'testing':
case 'production':
error_reporting(0);
break;
default:
exit('The application environment is not set correctly.');
}
}
Run Code Online (Sandbox Code Playgroud)
小智 5
每当我在autoload.php中像'数据库'那样自动加载内容时,就会发生这种情况.
要解决此问题,请使用Windows操作系统
打开你的php.ini.搜索并取消注释此行 - extension=php_mysql.dll
(另请检查如果PHP指令指向您的扩展所在的位置.
我的是extension_dir = "C:\php-5.4.8-Win32-VC9-x86\ext"
)
重启Apache并刷新页面
归档时间: |
|
查看次数: |
132430 次 |
最近记录: |