Checking string length with strlen

穿精又带淫゛_ 提交于 2019-12-02 23:56:28

问题


I have this code, i want it to check if the length is NOT 32 or 40. The code below only checks if the word is 32 or 40 in length.

<?
$name = mysql_real_escape_string($_POST['dgt']);
$len = strlen($name);
if (!($len == "32" or $len == "40")){
print "This is not a name.";
} else {
echo 'This is a name';
?>

回答1:


if ($len != 32 && $len != 40)

try that out




回答2:


What about

if($len != 32 and $len != 40)



回答3:


<?php
$name = mysql_real_escape_string($_POST['dgt']);
$len = strlen($name);
if ($len != 32 && $len != 40){
print "This is not a name.";
} else {
echo 'This is a name';
?>


来源:https://stackoverflow.com/questions/20629689/checking-string-length-with-strlen

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!