0

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?

W Six
  • 3
  • 2
  • Do you have error reporting and displaying enabled on the server? Have you checked the server error logs? – jrswgtr Mar 01 '20 at 10:46
  • I don't know. I had an old version of appserv and everything worked fine, this new version isn't doing what I expected. How do I even enable error reporting? – W Six Mar 01 '20 at 10:49
  • Does this answer your question? [How do I get PHP errors to display?](https://stackoverflow.com/questions/1053424/how-do-i-get-php-errors-to-display) – jrswgtr Mar 01 '20 at 10:51
  • Not really @jrswgtr - Most logical seems to be to set `display_errors = on` in php.ini, but I've tried this and it's still not working. – W Six Mar 01 '20 at 11:00
  • Ignore that. I removed `error_reporting(1);` and it's now working fine. – W Six Mar 01 '20 at 11:02

2 Answers2

0

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);
Bär Ger
  • 90
  • 5
  • Thanks. I added `error_reporting(1);` before the include statement but it's still not giving me an error message. – W Six Mar 01 '20 at 10:55
  • Try adding: ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); – Bär Ger Mar 01 '20 at 11:00
  • Update : I editied my php.ini file and this is now working. Any ideas about my first problem? – W Six Mar 01 '20 at 11:02
0

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

W Six
  • 3
  • 2