Does someone know how to make a script that is always included in a php file.
For Example, I have an index.php, I wanted to include script.php by doing include 'script.php';
Again, I have a login.php and I wanted to include script.php by doing include 'script.php';
I think this is very tiring to do and I think this is not a good idea because it is very repetitive. Is there a way where I can include script.php without doing include in each of the file? Like I should do that in a single file then everything would be affected.
Any idea would be greatly appreciated and rewarded. Thanks! 🙂
The only way to literally do what you are asking that I know of is through a config option:
auto_prepend_file
If your PHP code is OO, you could look into cleaner solutions such as autoload. Which I would recommend over the
auto_prepend_file. A step down from that would be just use 1 file that you do include from all of your other files maybe namedinit.php, but then anything else you need included to all of your files you add the include toinit.php. Not the cleanest solution, but easy and fast to implement and doesn’t involve any config changes.