Im currently building a php framework… again.
I have a class called config.
its pretty simple, its called like so:
$conf = config::get('general');
$conf is now an array full of config goodies.
the class sceleton is like so:
final class config {
private static $configs = array();
public static function get($name) {
return self::$configs[$name];
}
}
assume the $configs array is already populated and has a “general” key.
This “general” key holds an array that is exactly 1 megabyte.
Lets say I call
config::get('general');
10 times into different variables. None of the variables are edited afterwards… does this mean i have 10 variables each containing 1 megabyte or 10 variables pointing to 1 megabyte?
Only one, if you do not modify them.
But php is not the language where you can rely on any particular behavior 😉
Just tried:
output: