来自PHP的响应不符合预期
我正在尝试根据从应用程序发送到服务器的内容将数据从数据库发送到应用程序,如下所示:来自PHP的响应不符合预期,php,json,Php,Json,我正在尝试根据从应用程序发送到服务器的内容将数据从数据库发送到应用程序,如下所示: $search_bp=$_POST['search_bp']; $search_trig = 0; if(strcmp($search_bp,"1")==true){ //decisions that could set search_trig = 1; //eg if(strcmp($_POST['EStype'],'Event')){ if(strcmp($_P
$search_bp=$_POST['search_bp'];
$search_trig = 0;
if(strcmp($search_bp,"1")==true){
//decisions that could set search_trig = 1;
//eg
if(strcmp($_POST['EStype'],'Event')){
if(strcmp($_POST['type'],'Any')==false){
if(strcmp($_POST['type'],$row["type"])==false){
$search_trig=1;//doesnt match specs
}
}
}
}
if($search_trig == 0){
$event["pid"] = $row["pid"];
$event["name"] = $row["name"];
$event["longitude"] = $row["longitude"];
$event["latitude"] = $row["latitude"];
$event["pavement"] = $row["pavement"];
$event["traffic"] = $row["traffic"];
$event["environment"] = $row["environment"];
$event["image_b64"] = $row["image_b64"];
$event["date"] = $row["date"];
$event["time"] = $row["time"];
$event["type"] = $row["type"];
// push single product into final response array
array_push($response["events"], $event);
}
$response["success"] = 1;
// echoing JSON response
echo json_encode($response);
问题是,它strcmp($search\u bp,“1”)
似乎总是错误的,即使我以
params.add(new BasicNameValuePair("search_bp", Integer.toString(search_bp)));
在我知道的search\u bp=1
中,我只是对php不太了解,所以我很确定这只是我的语法
提前谢谢大家,
Tyler
strcmp
返回一个整数而不是布尔值。
如果str1小于str2,则返回<0;>如果str1大于str2,则为0;如果两者相等,则为0。
从技术上讲,您只需检查asif($search\u bp==“1”){
如果我们在php的松散类型世界中剖析您的语句,您可以看到您的错误
`strcmp` will return 0 because they do match.
0 = false
1 = true
所以
if(strcmp($search_bp,“1”)==true){
求解为if(0==true){
,然后if(0==1){
,这将不满足条件。strcmp
返回一个整数而不是布尔值。
如果str1小于str2,则返回<0;如果str1大于str2,则返回>0;如果两者相等,则返回0。
从技术上讲,您只需检查asif($search\u bp==“1”){
如果我们在php的松散类型世界中剖析您的语句,您可以看到您的错误
`strcmp` will return 0 because they do match.
0 = false
1 = true
所以
if(strcmp($search_bp,“1”)==true){
求解为if(0==true){
,然后if(0==1){
,这将不满足条件。strcmp
返回一个整数而不是布尔值。
如果str1小于str2,则返回<0;如果str1大于str2,则返回>0;如果两者相等,则返回0。
从技术上讲,您只需检查asif($search\u bp==“1”){
如果我们在php的松散类型世界中剖析您的语句,您可以看到您的错误
`strcmp` will return 0 because they do match.
0 = false
1 = true
所以
if(strcmp($search_bp,“1”)==true){
求解为if(0==true){
,然后if(0==1){
,这将不满足条件。strcmp
返回一个整数而不是布尔值。
如果str1小于str2,则返回<0;如果str1大于str2,则返回>0;如果两者相等,则返回0。
从技术上讲,您只需检查asif($search\u bp==“1”){
如果我们在php的松散类型世界中剖析您的语句,您可以看到您的错误
`strcmp` will return 0 because they do match.
0 = false
1 = true
因此
if(strcmp($search_bp,“1”)==true){
解为if(0==true){
,那么if(0==1){
将不满足条件。请注意strcmp不会返回true或false:
它返回如下
0 - if the two strings are equal
<0 - if string1 is less than string2
>0 - if string1 is greater than string2
在本例中,还可以使用==运算符
请注意:=仅返回真值或假值,它不会告诉您哪个是“大”字符串请注意strcmp不返回真值或假值: 它返回如下
0 - if the two strings are equal
<0 - if string1 is less than string2
>0 - if string1 is greater than string2
在本例中,还可以使用==运算符
请注意:=仅返回真值或假值,它不会告诉您哪个是“大”字符串请注意strcmp不返回真值或假值: 它返回如下
0 - if the two strings are equal
<0 - if string1 is less than string2
>0 - if string1 is greater than string2
在本例中,还可以使用==运算符
请注意:=仅返回真值或假值,它不会告诉您哪个是“大”字符串请注意strcmp不返回真值或假值: 它返回如下
0 - if the two strings are equal
<0 - if string1 is less than string2
>0 - if string1 is greater than string2
在本例中,还可以使用==运算符
请注意:=只返回true或false,它不会告诉您哪个字符串“更大”“似乎总是假的”…您确定吗?您确实意识到IF语句中没有任何内容:IF(strcmp($search\u bp,“1”)==true){…
“似乎总是假的”…你确定吗?你确实意识到在这个IF语句中没有任何东西:IF(strcmp($search\u bp,“1”)==true){…
“似乎总是错误的”…你确定吗?你确实意识到在这个IF语句中没有任何东西:IF(strcmp($search\u bp,“1”)==true){…
“似乎总是错误的”…你确定吗?你确实意识到IF语句中没有任何内容:IF(strcmp($search\u bp,“1”)==true){…