-2

I thought it might be good to see if my include file actually exists.

So I added this just before my include('../server/includes.php'); line; :

if(!file_exists('../server/includes.php'){
    echo 'Include file does not exist';
    exit;
}

Now I get an internal server error 500. If I take it back out the service runs up to the point where my include statement is then fails which is what prompted me to test if file existed.

This is in a web service api. Testing with latest Postman app.

Using php v5.6.30, Apache, xampp stack

Any ideas?

Mark Clark
  • 157
  • 2
  • 14

2 Answers2

0

There is no need to do that, PHP already has a predefined function

require('somefile.php');

manual

-1

You missed a parenthesis in your if statement :

Corrected code :

if( !file_exists('../server/includes.php') ){
echo 'Include file does not exist';
exit;
}
Inazo
  • 488
  • 4
  • 15
  • Do you know how many times I looked for little things like that! Funny I copied and pasted the code from a SO answer on how to test if the file existed and just changed the file name. Hanging my head in shame for missing that! – Mark Clark Apr 11 '20 at 00:44