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';
?>
if ($len != 32 && $len != 40)
try that out
What about
if($len != 32 and $len != 40)
<?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