Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set a Top Level or Super Duper Global Variable in PHP?

Tags:

php

Is it possible to make a Top Level Variable in PHP? Like Defining in .htaccess or httpd.conf? To be included in each .php file?

I would love to define BasePaths and some other variables there if possible. I am currently making some init.php and including 'em on top if each file.

like image 980
tika Avatar asked Oct 19 '22 10:10

tika


1 Answers

As your working with a multi entry point application, if you want to avoid including your configuration file, you can use the php's autoprepend functionality. This will automatically include a file for you without the need to do a <?php require('init.php'); ?> in each of you entry points.

And you can find a good advice here.

like image 60
David Jacquel Avatar answered Oct 22 '22 02:10

David Jacquel