I'm trying to check value's of keys :
我正在检查键的值:
$errorArray=array();
$naamarray["naam"]=false;
$naamarray["voornaam"]=false;
$naamarray["adres"]=false;
$naamarray["woonplaats"]=false;
$naamarray["postcode"]=false;
$naamarray["telefoonnummer"]=false;
$naamarray["geboortedatum"]=false;
$naamarray["adres"]=false;
$naamarray["wachtwoord"]=false;
$naamarray["email"]=false;
$naamarray["email"]=true;
foreach($naamarray as $key => $value){
if($value == false){
array_push($errorArray,$key);
echo $key;
echo $value;
}
}
But the value never get's shown, what is my mistake ?
但是价值从来没有被显示出来,我的错误是什么?
6 个解决方案
#1
4
The false
is boolean type in php. Since you have assigned that to your array values, you need to use var_dump
to see actual value for your keys :
错误是php中的布尔类型。由于已经将其分配给数组值,因此需要使用var_dump查看键的实际值:
var_dump($key);
See the var_dump
manual for more info
更多信息请参见var_dump手册。
You may want to assign string values to your array values instead.
您可能希望将字符串值分配给数组值。
#2
1
Please note: echo false
does not echo anything.
请注意:echo false没有回音。
#3
1
because they are always false, it means NOTHING
因为它们都是假的,所以没有任何意义
echo false;
gives you
给你
#4
0
Try this:
试试这个:
$errorArray=array();
$naamarray["naam"]='false';
$naamarray["voornaam"]='false';
$naamarray["adres"]='false';
$naamarray["woonplaats"]='false';
$naamarray["postcode"]='false';
$naamarray["telefoonnummer"]='false';
$naamarray["geboortedatum"]='false';
$naamarray["adres"]='false';
$naamarray["wachtwoord"]='false';
$naamarray["email"]='false';
$naamarray["email"]='true';
foreach($naamarray as $key => $value){
if($value == 'false'){
array_push($errorArray,$key);
echo $key;
echo $value;
}
}
#5
0
You cannot echo a boolean variable in PHP. If you just want to debug - use
不能在PHP中回显布尔变量。如果你只是想调试-使用
var_dump($value);
instead.
代替。
#6
0
Funny, the keys do echo on my home server. But then again; echo'ing bool false will not output anything.
有趣的是,钥匙在我家的服务器上发出回声。但话又说回来,echo' bool false不会输出任何东西。
#1
4
The false
is boolean type in php. Since you have assigned that to your array values, you need to use var_dump
to see actual value for your keys :
错误是php中的布尔类型。由于已经将其分配给数组值,因此需要使用var_dump查看键的实际值:
var_dump($key);
See the var_dump
manual for more info
更多信息请参见var_dump手册。
You may want to assign string values to your array values instead.
您可能希望将字符串值分配给数组值。
#2
1
Please note: echo false
does not echo anything.
请注意:echo false没有回音。
#3
1
because they are always false, it means NOTHING
因为它们都是假的,所以没有任何意义
echo false;
gives you
给你
#4
0
Try this:
试试这个:
$errorArray=array();
$naamarray["naam"]='false';
$naamarray["voornaam"]='false';
$naamarray["adres"]='false';
$naamarray["woonplaats"]='false';
$naamarray["postcode"]='false';
$naamarray["telefoonnummer"]='false';
$naamarray["geboortedatum"]='false';
$naamarray["adres"]='false';
$naamarray["wachtwoord"]='false';
$naamarray["email"]='false';
$naamarray["email"]='true';
foreach($naamarray as $key => $value){
if($value == 'false'){
array_push($errorArray,$key);
echo $key;
echo $value;
}
}
#5
0
You cannot echo a boolean variable in PHP. If you just want to debug - use
不能在PHP中回显布尔变量。如果你只是想调试-使用
var_dump($value);
instead.
代替。
#6
0
Funny, the keys do echo on my home server. But then again; echo'ing bool false will not output anything.
有趣的是,钥匙在我家的服务器上发出回声。但话又说回来,echo' bool false不会输出任何东西。