1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| function ConvertVariables($content) {
preg_match_all('/\$(\w+)/i', $content, $matches);
foreach($matches[1] as $match){
global ${$match};
$content = str_replace("$".$match,${$match},$content);
}
return $content;
}
function recup() {
$html = 'Bonjour $nom, ton adresse mail est : $email';
return $html;
}
function affichage() {
$nom = 'Pierre';
$email = 'pierre@domaine.com';
$message = ConvertVariables(recup());
return $message;
}
echo affichage();
// Donne
Bonjour , ton adresse mail est : |