📅  最后修改于: 2022-03-11 14:54:20.645000             🧑  作者: Mango
You could also use strtr:
$template = '$who likes $what';
$vars = array(
'$who' => 'tim',
'$what' => 'kung pao',
);
echo strtr($template, $vars);
Outputs:
tim likes kung pao