Check if an include (or require) exists

I believe file_exists does work with relative paths, though you could also try something along these lines…

if(!@include("script.php")) throw new Exception("Failed to include 'script.php'");

… needless to say, you may substitute the exception for any error handling method of your choosing. The idea here is that the if-statement verifies whether the file could be included, and any error messages normally outputted by include is supressed by prefixing it with @.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)