I\'ve been developing in PHP for a while now, and I still have not had a task where I\'ve had to use variable variables. Can anyone give me examples where using them is a go
I've found a quite good one..
$php = "templates/php/default.php";
$html = "templates/html/default.php";
$css = "templates/css/default.php";
$js = "templates/js/default.php";
now i asked the user to say which file he wants php or/and html..
$userarray = array("php", "css");
foreach($userarray as $file){
var_dump($$file);
}
output:
templates/php/default.php
templates/css/default.php
I've crossed myself with this when trying to scope static variables
self::$file;
like this then I remembered I could use variable variables
self::$$file;
which will be interpreted as self::$php;