php 变量名再赋予变量

<?php 
$like = "apple"; //定义 like 的值为 apple
$revariable = "relike_".$like; //定义重新变量
$relike_apple = "banana"; //定义重新的值
echo $like."<br>"; //apple
echo $revariable."<br>"; //relike_apple
echo $relike_apple."<br>"; //banana
echo $$revariable."<br>"; //banana
<?php
$like = "apple";
$apple = "banana";
echo $$like; //banana
<?php
$like = "apple"; $apple = "banana"; $banana = "orange";
echo $like; //apple 
echo $$like; //banana 
echo $$$like; //orange 
... 无限延续

0 条评论

昵称

沙发空缺中,还不快抢~