Im Building an MVC Structure Application in Php. Ive Created A Config Class that calls a config file with settings in an array so that I can choose what to set in an OOP way
example - config_arrays.php in ./root/application/config
//Set System Url
$systemURL['devUrl'] = "http://localhost/Rush/";
$systemURL['liveUrl'] = 'http://www.relution-homes.com/';
example - config-class.php in ./root/system/core/
function SetBaseUrl($systemURL) {
if (Rf_Environment == 'Development') {
define('Rf_URL', $systemURL['devUrl']);
} elseif (Rf_Environment == 'Production') {
define('Rf_URL', $systemURL['liveUrl']);
} else {
die('Please Set Application Environment in the Applications Root index File');
}
}
Usage - to call the class takes place in the bootstrap folder I use spl_autoload_register after calling in the config_arrays then do this
// Create a new Instance of the Config Class
$Config = new Config();
// Set The Base Url
$Config->SetBaseUrl($systemURL);
And then heres where the fun starts . . .i use
<?php echo Rf_Url; ?>
in a page and it works fine try using it in a menu
<li><a href="<?php echo Rf_Url;?>index">Home</a></li>
And I get 'USE OF UNDEFINED CONSTANT Rf_Url - Assumed Rf_URL
I have looked at
What does the PHP error message "Notice: Use of undefined constant" mean?
And
"Use of undefined constant" notice, but the constant should be defined
With No definite answers . . .I've tried Double Quoting Everything Single Quoting Did think I could use isset() but then realized that this may not be beneficial in the long run.