I am a JS programmer who got thrown to PHP a few days ago and I'm trying to make a bit of sense. I've created a basic environment setup in FILE1 on Codeigniter for our server and choose the env on :
-----File1:----
$environments['default'] = array(
'db_hostname' => '*****1.amazonaws.com',
'base_url' => 'https://****co',
'name' => 'default'
);
$environments['local'] = array(
'db_hostname' => '*****2.amazonaws.com',
'base_url' => 'https://local.****co',
'name' => 'local'
);
-----File2:----
<?php
require_once __DIR__ .'/environments_config.php';
$env = $environments['local'];
So far so good,when I tried to use it on the config file in codeigniter it didn't work without the global keyword.
require_once __DIR__ .'/environment.php';
global $env; ///without global it doesn't work?
$config['base_url'] = $env['base_url'];
Maybe I'm missing something but shouldn't I declare a global variable only inside a function? because on File2 this setup works fine without a global declaration. Maybe its something related to Codeigniter that I'm missing?.