Php 如果数组中的值大于16或小于4,则为Die

Php 如果数组中的值大于16或小于4,则为Die,php,arrays,Php,Arrays,所以我想让这段代码检查数组中的所有值是小于16还是大于4 $username = $_POST['username']; $password = $_POST['password']; $details = array($username, $password); foreach($details as $detail){ $len = strlen($detail); if($len>16 || $len<4) { die('Too short');

所以我想让这段代码检查数组中的所有值是小于16还是大于4

$username = $_POST['username'];
$password = $_POST['password'];
$details = array($username, $password);

foreach($details as $detail){
    $len = strlen($detail);
    if($len>16 || $len<4) {
    die('Too short');
    }
}
$username=$\u POST['username'];
$password=$_POST['password'];
$details=数组($username,$password);
foreach($details作为$detail){
$len=strlen($detail);

如果($len>16 | |$len你的处理程序没有问题,我用一个简单的表格测试了一下,效果100%

检查您的表单是否受到(命名输入)的影响,例如:




为什么我不能输入超过16个字符的密码?我会让你知道我的密码是“超长密码,没有人会猜到”:老实说,我甚至不知道,只是为了练习,我猜。在foreach中添加
var_dump($detail);
输出是什么?字符串(6)“qwerty”字符串(9)“dffasasdf”@克里斯:那么现在——你为什么认为这会触发
die()
语句?
<input type="text" name="username">
<input type="text" name="password">