if语句不工作(PHP)
此if语句不工作(PHP),php,if-statement,Php,If Statement,此if语句导致固定作业和其他不应返回的结果的混合。不明白为什么这么简单的东西不起作用 if($item["total_spent"] >= '1000' && ($item["country"] == 'United States' || $item["country"] == 'Canada') && ($item["job_duration"] == '3 to 6 months' || $item["job_duration"] =
if
语句导致固定作业和其他不应返回的结果的混合。不明白为什么这么简单的东西不起作用
if($item["total_spent"] >= '1000'
&& ($item["country"] == 'United States' || $item["country"] == 'Canada')
&& ($item["job_duration"] == '3 to 6 months' || $item["job_duration"] = 'More than 6 months')
&& ($item["job_engagement"] == 'Full-time - 30+ hrs/week' || $item["job_engagement"] = 'Part-time - 10-30 hrs/week')
&& ($item["job_type"] == 'Hourly') )
也许,你的意思是:
if($item["total_spent"] >= '1000'
&& ($item["country"] == 'United States' || $item["country"] == 'Canada')
&& ($item["job_duration"] == '3 to 6 months' || $item["job_duration"] == 'More than 6 months')
&& ($item["job_engagement"] == 'Full-time - 30+ hrs/week' || $item["job_engagement"] == 'Part-time - 10-30 hrs/week')
&& ($item["job_type"] == 'Hourly') )
注意,在一些where子句中使用了single
=
,看起来代码中有几个意外的赋值,下面的方法有效吗
<?php
if($item["total_spent"] >= '1000'
&& ($item["country"] == 'United States' || $item["country"] == 'Canada')
&& ($item["job_duration"] == '3 to 6 months' || $item["job_duration"] == 'More than 6 months')
&& ($item["job_engagement"] == 'Full-time - 30+ hrs/week' || $item["job_engagement"] == 'Part-time - 10-30 hrs/week')
&& ($item["job_type"] == 'Hourly')
) {
// ...
}
这些行的写入方式与赋值相同,它们应为:
$item["job_engagement"] == 'Part-time - 10-30 hrs/week'
$item["job_duration"] == 'More than 6 months'
在某些情况下,您有single=
$item["job_engagement"] == 'Part-time - 10-30 hrs/week'
$item["job_duration"] == 'More than 6 months'