Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You have a few options:</p> <p><strong>Use PHP Namespaces</strong></p> <p>Surprisingly, PHP actually does have support for <a href="http://us2.php.net/manual/en/language.namespaces.php" rel="nofollow noreferrer">namespaces</a>. I was very surprised to find this since I have been working in PHP for years and have never heard of this feature. It is likely a newer feature and one that is not commonly used, so I would suggest not using this method</p> <p><strong>Use Class Constants</strong></p> <p>You could use classes and <a href="http://php.net/manual/en/language.oop5.constants.php" rel="nofollow noreferrer">class constants</a> to load your settings. Class constants are local to the defining class, so you will not need to worry about name collisions within the class. You would probably need to do more than include the file, but you could call a method on each class, such as defineConstants() or loadConfiguration() that would define the application constants, keeping the class constants for internal use.</p> <p><strong>Use Functions to Extend the Settings</strong></p> <p>Another idea is to create a settings array and separate functions to 'extend' those settings. That way you can over-write any configuration in subsequent functions without causing an error. Finally, if you want to put those in constants, you could loop over the array and use define() to define the constants.</p> <p>There are many other ways to accomplish what you are trying to do, but these are just a few ideas.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload