用PHP语言如何来判断?

来源:百度知道 编辑:UC知道 时间:2024/06/05 11:18:06
有两个变量
$read[author]
$read[userip]
只让它显示出一个变量的数据。

如果$read[author]变量等于=匿名,就显示$read[userip]
如果$read[author]为IP数据,就直接显示。

麻烦懂PHP的人,写一下,谢谢了。

哎哟喂.就一个if语句吗
if($read[author]=="匿名"){
echo $read[userip];
}else{
echo $read[author];
}
其它什么杂七杂八的都不要..

if ($read[author]=='匿名'){
echo $read[userip];
}else{
echo $read[author];
}

if($read[author]!=""&&$read[author].lenght>0)
{
if($read[author]=="匿名")
echo $read[userip];
else{
if(ereg("^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$",$read[author]))
{
echo $read[author];
}
}
}

类似于这样吧。具体语法可能会有点错误。你调试一下。

5