vendredi 12 mars 2021

Why isn't this variable our of context? [duplicate]

I'm learning PHP and I encounter this piece of code:

$args = [
    "msg" => "hello world!"
];

foreach ($args as $key => $value) {
    $$key = $value;
}

echo $msg; // prints hello world!

Why can I acces $msg if it was created inside the for loop? Shouldn't it be out of context?




Aucun commentaire:

Enregistrer un commentaire