I looked at “ini” files and also setting and putting environment variables:
https://www.php.net/manual/en/function.putenv.php
https://www.php.net/manual/en/function.getenv.php
Conclusion
I’m busy with setting environment variables for a common application that is used on three different sites and setting variables is becoming clumsy.
I read somewhere that setting constants is a lot faster and now also accepts arrays I’ve decided to revamp the way I used to define constants. The idea is that it is a lot simpler while developing to test the current site settings.
Demo to setting site PHP CONSTs
// file: config.php
<?php declare(strict_types=1);
if( 0 ): // site_000.com
define('aENV',
array(
'one_001' => 'asdf-000',
'two_002' => 'asdf-000',
'three_003' => 'asdf-000',
)
);
elseif(0) : // site_001.com
define('aENV',
array(
'one_001' => 'ASDF-001',
'two_002' => 'ASDF-001',
'three_003' => 'ASDF-001',
)
);
elseif(0) : // site_002.com
define('aENV',
array(
'one_001' => 'qwerty-002',
'two_002' => 'qwerty-002',
'three_003' => 'qwerty-002',
)
);
else : // site_DEFAULT.com
define('aENV',
array(
'one_001' => 'DEFAULT_003',
'two_002' => 'DEFAULT_003',
'three_003' => 'DEFAULT_003',
)
);
endif;
fred( aENV, 'aENV' );
//===================================================
function fred($val='Nothing passed', $title=NULL)
{
$title = $title
? 'Title ==> ' .$title
: '$title ==> Yes we have no $title' ;
echo '<br><hr><pre>' .$title .'<br>';
print_r($val);
echo '<pre><hr><br>';
}
//===================================================
Output:
Title ==> aENV
Array
(
[one_001] => DEFAULT_003
[two_002] => DEFAULT_003
[three_003] => DEFAULT_003
)