当 $pre="r" 时正常,但当 $pre="_POST" 时就取不到表单传来的值,是怎么回事呢?

解决方案 »

  1.   

    ${$pre}['abc'];试试和php.ini中设置有关.
      

  2.   

    试过也是不行,直接用 $_POST['abc'] 是可以取到值的,但用上面的组合就总是空,输出 $pre 的值发现是正确的 _POST
      

  3.   

    是吗?
    <form method=post>
    <input name=a value=3>
    <input type=submit>
    </form><?php
    $p = "_POST";
    echo ${$p}['a'];
    ?>
      

  4.   

    我都不知是什么回事了:(我提交 1234,然后用 <?echo $pre;?> | <?echo ${$pre}['abc'];?> | <?echo $_POST['abc'];?> 做测试,结果输出结果 _POST | |1234,还是取不到值:(
      

  5.   

    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <script>
    function submitchoice(){
    editform.method="post"
    editform.action="editstu.php?action=listchoice"
    editform.submit();
    }
    </script>
    <link href="images/main.css" rel="stylesheet" type="text/css">
    </head>
    <?
    function stuinfo($formaction){
      if($formaction=="fromform"){
          require('global.php');
          require('function.php');
      $pre = "_POST";
      }
      if($formaction=="fromdb"){
          require('global.php');
          require('function.php');
          mysql_select_db($mysql_data);
          $query="select * from ".$table_stuinfo_base." where id='".$_REQUEST['id']."'";
          $result=mysql_query($query);
          $r=mysql_fetch_array($result);
          $pre="r";
      }
    ?>
    <body bgcolor="#E6F3FF">
    <form name="editform" method="post" action="editstu.php?action=save">
      <table width="550" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr> 
          <td bgcolor="#FFFFFF"><table width="100%" border="0">
              <tr bgcolor="#B5DBFF"> 
                <td height="25" colspan="4"><div align="center"><strong>学生基本信息处理</strong></div></td>
              </tr>
              <tr bgcolor="#DAEDFF"> 
                <td width="20%" bgcolor="#DAEDFF"><div align="left">学 籍 号</div></td>
                <td width="30%" bgcolor="#E6F3FF"><input name="xjh" type="text" size="20" value="<?echo ${$pre}['xjh'];?>"></td>
              <tr bgcolor="#DAEDFF"> 
                <td width="20%" bgcolor="#DAEDFF"><div align="left">籍 贯 码</div></td>
                <td colspan="3" bgcolor="#E6F3FF"><select name="jgm" id="select3" onchange="submitchoice();">
                    <?showchoice($table_GB_T2260,$_POST['jgm']);    // 读取籍贯码?>
                  </select> <div align="left"></div></td>
              </tr>
              <tr bgcolor="#DAEDFF"> 
                <td bgcolor="#DAEDFF">出生地码</td>
                <td colspan="3" bgcolor="#E6F3FF"><select name="csdm" id="select">
                    <?listchoice($table_GB_T2260a,$_POST['jgm']);    // 读取出生地码?>
                  </select></td>
              </tr>
              <tr bgcolor="#DAEDFF"> 
                <td height="25" colspan="4" bgcolor="#DAEDFF"><div align="center"> 
                    <input type="submit" name="Submit" value="提 交">
                      
                    <input type="reset" name="Submit2" value="重 写">
                  </div></td>
              </tr>
            </table></td>
        </tr>
      </table>
    </form>
    </body>
    <?
    mysql_close();
    }
    ?>
    </html>
    <?
    require('global.php');
    mysql_select_db($mysql_data);
    if($_REQUEST['action']=='save'){}elseif($_REQUEST['action']=='listchoice'){
       $formaction="fromform";
       stuinfo($formaction);
    }else{
       $formaction="fromdb";
       stuinfo($formaction);
    }
    ?>