有可能使用PHP制作类似的东西吗?
<?php
$number = 1;
$str_$number = "BlahBlah";
// and make this: $str_1 = "BlahBlah";
echo $str_1;
?>
答案 0 :(得分:2)
<?php
$number = 1;
${'str_'.$number} = 'foobar';
echo $str_1;//foobar
答案 1 :(得分:1)
尝试
<?php
$number = 1;
${'str_' . $number} = 'foobar';
?>
答案 2 :(得分:1)
<?php
$number = 1;
$value = 'str_' . $number;
$$value = 'blahblah';
echo $str_1;
?>
答案 3 :(得分:0)
您也可以尝试
$number = 1;
eval('$str_'.$number.' = "foobar";');
echo $str_1;