函数里面如何由参数变量$what得到$what_1?<?php
$good_1="good";
$bad_1="bad";function hello($what){
echo $what_1; // 请问这里怎么写才让输入$what变量输出$what_1变量内容?
}hello("good");?>

解决方案 »

  1.   

    <?php
    $good_1="good";
    $bad_1="bad";function hello($what){
        $new = $what.'_1';
        echo $GLOBALS[$new];
    }hello("good");?>
      

  2.   

    $good_1="good";
    $bad_1="bad";function hello($what){
        global $good_1,$bad_1;
        eval("echo $".$what."_1;");
    }hello("good");
      

  3.   

    function hello($what){
        $v =  "{$what}_1";
        echo $$v;
    }