drngnh708353 2013-11-09 12:53
浏览 33


I am running newest version of WAMPServer on Windows 7 Home Premium. It accesses database (remote) fine, it runs basic PHP fine. My issue is with variable variables. On my godaddy server, the exact code runs fine.

When I try to include a file that uses variable variables (in this case $state{$i}) in WAMPServer says:

Notice: Undefined variable: state in E:\wamp\www\CCRN411\inc\state_drop_down.inc.php on line 2.

Note that it is looking for state, not state1 as the code generates for $i= 1 which I declare on the first line of the same file.

<select class="dropdownState" name="<?php $i=1; echo 'state' . $i; ?>" id="<?php echo 'state' . $i; ?>">
<option value="DL" <?php if ($state{$i} == "DL") {echo ('selected="selected"');} ?>>DELETE</option>
<option value="ZZ" <?php if ($state{$i} == "ZZ") {echo ('selected="selected"');} ?>>NONE</option>

If I add

$state1 = . and it is empty. What is the issue with my variable variable?

Help please.

  • 写回答

1条回答 默认 最新

  • dongshi1188 2013-11-09 13:29

    Wrong syntax. You want ${"state$i"}, as in

    if (${"state$i"} == "DL") ...
    本回答被题主选为最佳回答 , 对您是否有帮助呢?



  • ¥15 gwas 分析-数据质控之过滤稀有突变中出现的问题
  • ¥15 没有注册类 (异常来自 HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
  • ¥15 知识蒸馏实战博客问题
  • ¥15 用PLC设计纸袋糊底机送料系统
  • ¥15 simulink仿真中dtc控制永磁同步电机如何控制开关频率
  • ¥15 用C语言输入方程怎么
  • ¥15 网站显示不安全连接问题
  • ¥15 51单片机显示器问题
  • ¥20 关于#qt#的问题:Qt代码的移植问题
  • ¥50 求图像处理的matlab方案