如果您指定的是x=john或bond结果,如何显示
<?php
if ($x == "john")
{
?>
you name is john or bond
<?php } ?>发布于 2016-06-18 12:49:13
if ($x == "john" || $x == "bond")
{
// do stuff
}或者,如果您有多个名称,则可以使用其他结构,如switch()
switch ($x)
{
case "john":
case "bond":
// do something
break;
default:
// or else do this
}如果你有一个动态的名字列表,或者你只是觉得它更易读,你也可以使用in_array():
if (in_array($x, ["john", "bond"]))
{
// do stuff
}发布于 2016-06-18 13:44:20
试试这个:
<?php
$x="bond";
//$x="john";
if ($x == "john" or $x == "bond") {
echo "Your name is ".$x;
}
?>https://stackoverflow.com/questions/37893342
复制相似问题