无法使 php 条件化“if”在 HTML 中工作
我的代码如下;
<select class="reg_field_field" id="user_address_state" name="user_address_state" tabindex="7">
<option value="AL" <?php if($state=='AL') echo 'selected';?>/>Alabama</option>
<option value="AK" <?php if($state=='AK') echo 'selected';?>/>Alaska</option>
<option value="AZ" <?php if($state=='AZ') echo 'selected';?>/>Arizona</option>
....
</select>
结果显示的是状态名称,它显示“注意:未定义的变量...”。
我在其他服务器上尝试过并工作,可能是 php.ini 配置??? php.ini 上可以有什么?
的帮助
谢谢你
my code is the following;
<select class="reg_field_field" id="user_address_state" name="user_address_state" tabindex="7">
<option value="AL" <?php if($state=='AL') echo 'selected';?>/>Alabama</option>
<option value="AK" <?php if($state=='AK') echo 'selected';?>/>Alaska</option>
<option value="AZ" <?php if($state=='AZ') echo 'selected';?>/>Arizona</option>
....
</select>
And the result is showing me instead the state name, it show "Notice: Undefined variable...".
I tried this in other server and worked, could be the php.ini configuration???
What can be on php.ini?
Thank you for any help
Ale
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
该错误告诉您问题:
$state
未定义。您需要检查代码以确定应在何处定义$state
并确保其设置正确。如果您尝试将用户输入保存到
$state
变量,请查找如下行:如果不存在,请在帖子中包含的行之前创建它。
The error tells you the problem:
$state
is undefined. You need to examine your code to determine where$state
should be defined and ensure that it is being set properly.If you are attempting to save user input to the
$state
variable, look for a line like:If it does not exist, create it prior to the lines you included in your post.
$state 有默认值吗?在检查它是否与另一个匹配之前,它必须具有一个值。
does $state have a default value? It has to have a value prior to checking to see if it matches against another.