switch 函数变量不显示
我有这个开关函数,它应该获取查询字符串中传递的参数的值,并根据它决定变量的值:
<?php
switch($_REQUEST['textcolor']){
case "white":
$textcolor = $white;
break;
case "black":
$textcolor = $black;
break;
}
?>
$_REQUEST
从以下链接获取它的值:
<a href="index2.php?status=Busy&codigo2=<?php echo $codigo2; ?>&textcolor=white">
这是我有一个隐藏元素的形式,它应该显示值,但没有:
<form>
<input type="hidden" value="<?= $textcolor ?>">
</form>
任何想法为什么 $textcolor
变量不显示?
编辑:已解决,原因确实是未声明变量。谢谢!
I've got this switch function that is suppose to get the value of a parameter passed in a query string, and upon it decide the value of the variable:
<?php
switch($_REQUEST['textcolor']){
case "white":
$textcolor = $white;
break;
case "black":
$textcolor = $black;
break;
}
?>
The $_REQUEST
gets it's value from this link:
<a href="index2.php?status=Busy&codigo2=<?php echo $codigo2; ?>&textcolor=white">
and this is the form in which I have a hidden element that;s suppose to show the value, but does not:
<form>
<input type="hidden" value="<?= $textcolor ?>">
</form>
Any ideas why the $textcolor
variable is not showing?
EDIT: Solved, the reason was indeed variable not declared. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
$white 和 $black 是在哪里定义的?
编辑
做:
看看会发生什么
Where are $white and $black defined?
EDIT
Do:
and see what happens
在
switch
中添加最后一个case
Add a last
case
in theswitch