skip to Main Content

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); ?> 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?

2

Answers


  1. Chosen as BEST ANSWER

    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


  2. 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);
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search