Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP including other php files question

Tags:

php

I have a web page that has many php files in it and I was wondering how can I stop users from viewing the php includes individually?

like image 250
HELP Avatar asked May 24 '26 21:05

HELP


1 Answers

One popular way is to define a constant in the including file:

define ("INCLUDE_OK", true);

and then to check in every sub-include:

if (!defined("INCLUDE_OK")) die ("This file can't be executed directly");

Alternatively, as @mikerobi says in his now deleted answer, store the include files in a folder outside the web root.

like image 72
Pekka Avatar answered May 26 '26 10:05

Pekka



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!