简体   繁体   中英

Localhost - PHP Include Not Showing Errors

I've just installed the latest version of Appserv ( 9.3.0 ), which includes:

Apache 2.4.41
PHP 7.3.10
MySQL 8.0.17
phpMyAdmin 4.9.1

I'm using Localhost as my root directory and trying to reuse old files to build a new website, but I'm noticing a problem.

I'm using the include() function, but there is a problem.

<?php include(file.php); ?> <?php include(file.php); ?> shows the contents of file.php , but, if I delete file.php , it doesn't give me an error message saying file.php could not be found . Why is this?

Answer to secondly:

include() on a non-existent file produces an error of type E_WARNING . For testing purposes simply add this line of code

error_reporting(1);

before using an include() statement.

For production you should avoid displaying any kind of errors. You can register your own error handler with set_error_handler() .

set_error_handler(function ($no, $err, $file, $line)
{
    // do whatever you want to if an error of type E_WARNING occurs
}, E_WARNING);

In Windows 10, go to:

Start > Appserv > PHP Edit php.ini

Find line : display_errors Off and change to display_errors On

Save & Close

Start > AppServ > Apache Restart

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM