我试图在if/else语句中获取一个值,并发送一个带有“该变量”的错误消息,因为我不希望我的任何输入超过99个字符。
代码如下:
if(empty($x) || empty($y) || empty($z)){
$_SESSION["ErrorMessage"]="You have to fill all the blanks.";
redirect_to("addxyz.php");
} elseif(strlen($x)>99 || strlen($y)>99 || strlen($z)>99){
$_SESSION["ErrorMessage"]="Very Long Name for /*variable name will be here*/";
redirect_to("addxyz.php");
} else {/*Rest of the code*/}
在第二部分中,当我使用带有变量的strlen函数时,我需要使用数组或任何其他方法来选择其中一个,而不是使用3个不同的if/else语句。最好的方法是什么?
提前谢谢。
https://stackoverflow.com/questions/50866603
复制相似问题