Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP auto include

Tags:

php

I want to auto include a PHP script onto every exection into the server, I was hopping to do it via the PHP ini, via a setting or being able to write an extention in php that was simple and included my php script.

like image 475
WojonsTech Avatar asked Dec 26 '12 00:12

WojonsTech


People also ask

What is include () in PHP?

The include (or require ) statement takes all the text/code/markup that exists in the specified file and copies it into the file that uses the include statement. Including files is very useful when you want to include the same PHP, HTML, or text on multiple pages of a website.

What is an autoloader in PHP?

Autoloading in the “Olden Days” PHP 5 introduced the magic function __autoload() which is automatically called when your code references a class or interface that hasn't been loaded yet. This provides the runtime one last chance to load the definition before PHP fails with an error.

How do you autoload in PHP?

The spl_autoload_register() function registers any number of autoloaders, enabling for classes and interfaces to be automatically loaded if they are currently not defined. By registering autoloaders, PHP is given a last chance to load the class or interface before it fails with an error.


1 Answers

You can set the auto_prepend_file directive in your php.ini file:

http://php.net/manual/en/ini.core.php#ini.auto-prepend-file

like image 77
Lock Avatar answered Oct 06 '22 00:10

Lock