$service3_step1_person = ‘999’;
echo $service3_step1_person; //999
进而...
$service = "service3";
echo "$".$service."_step1_person; //$service3_step1_person
它没有给我999,只是给我一串$service3_step1_person
.
如何使字符串成为新的变量名?谢谢!
$service3_step1_person = ‘999’;
echo $service3_step1_person; //999
进而...
$service = "service3";
echo "$".$service."_step1_person; //$service3_step1_person
它没有给我999,只是给我一串$service3_step1_person
.
如何使字符串成为新的变量名?谢谢!
echo ${$service."_step1_person"};
变量变量:
$service3_step1_person = ‘999’;
$service = "service3";
$variableName = "{$service}_step1_person";
echo $$variableName; // 999
试试这个:
$service = "service3";
$temp = "_step1_person";
echo ${$service.$temp};