So kann man Variable permanent (Laufzeit) speichern.
<?php
myvars( ["city" => "bonn" ] );
myvars( ["alter" => "33" ] );
myvars( ["auto" => "bmw" ] );
echo " Stadt: " . myvars("city");
echo " Alter: " . myvars("alter");
echo " Auto: " . myvars("auto");
function myvars( $arr ){
static $vars;
if( is_array($arr) ){
$key = key( $arr );
$vars[ $key ] = $arr[ $key];
} else {
return $vars[ $arr];
}
}
?>
Neuen Kommentar schreiben