E_STRICT and display_errors = On in php.ini file or either you can use command in your php code to turn it on

问题描述 投票:0回答:3
ini_set("display_errors", 1); error_reporting(E_ALL);.

register.phpRequirerequire('config.php'):-require will produce a fatal error (E_COMPILE_ERROR) and stop the script. require('config.php')include

:-include will only produce a warning (E_WARNING) and the script will continue.require

<?php

require('config.php');
if (isset($_POST['submit'])) {
} else {
    $form = <<<EOT
<form action="register.php" method="POST">
First Name: <input type="text" name="name" /> <Br/>
Last Name: <input type="text" name="lname" /> <Br/>
Username: <input type="text" name="uname" /> <Br/>
Email: <input type="text" name="email1" /> <Br/>
Email2: <input type="text" name="email2" /> <Br/>
Pass: <input type="password" name="pass1" /> <Br/>
Pass2: <input type="password" name="pass2" /> <Br/>
<input type="submit" value="register" name="submit" />      
</form>
EOT;
    echo $form;
}
我正在用PHP写一段代码,还没有完全完成。当我打开这个
php require
3个回答
7
投票

一切都会出现在我的浏览器中。require你能不能帮帮我,告诉我,我的浏览器是怎么了?config.php?

ini_set("display_errors", 1);
error_reporting(E_ALL);

我正在用PHP写一段代码,但还没有完全完成,当我在浏览器中打开这个register.php脚本时,只有一个空白的页面,因为我无法通过require(config.php)。当我在浏览器中打开register.php脚本时,只有一个空白的页面,因为我无法越过require('config.php')。当我删除...

这是因为

函数将查找该文件

. 如果没有找到,就会给你一个错误。只有当你在文档中加入以下几行时,这个错误才会出现。

取自...


PHP文档require:include

require和include是一样的,只是一旦失败,它也会产生一个致命的E_COMPILE_ERROR级错误。换句话说,它将停止脚本,而include只会发出一个警告(E_WARNING),允许脚本继续。config.php config.php参见include文档了解其工作原理。register.php如果你想让 PHP 在找不到文件的时候不给你一个错误,你可以用下面的代码代替

config.php. 这意味着当它没有找到文件时,它仍然会在之后运行代码。require为了解决实际问题,你可以检查是否有

是在正确的地方。如果不是这样,请创建一个名为

0
投票

是。如果你的 是在正确的位置,检查该文件是否有任何错误,如果有,则检查该文件的 函数不能正常工作。

说明

:-发生这种情况是因为如果你使用require('config.php');这意味着它需要有 "config.php "这个文件,如果php无法找到这个文件,它将给你一个致命的错误,但正如你所说的,它不会显示任何东西,在你的 php.ini 文件中要么display_error是关闭的,要么就是没有设置error_reporting,所以你需要设置error_reporting = E_ALL或者error_reporting = E_ALL。 所以你需要设置 error_reporting = E_ALL 或 error_reporting = E_ALL。

© www.soinside.com 2019 - 2024. All rights reserved.