如果条件匹配,否则当我插入$ total_salary = 10000和$ salary_type = NO时条件不起作用。
if ($this->request->is('post')) {
$DATA = $this->data;
$employee_salary = $this->Salary->save($DATA);
$total_salary = $employee_salary['Salary']['salary'];
$salary_type = $employee_salary['Salary']['salary_in_ctc'];
echo $total_salary . $salary_type;
if (($total_salary > 15000) && ($salary_type === 'YES')) {
$pf_company = 1500;
$pf_employee = 1500;
$percent = 0.62;
$gross_salary = ($total_salary - $pf_company);
$base_salary = ($percent * $gross_salary);
$HRA = ($base_salary / 2);
$others = ($gross_salary - ($base_salary + $HRA));
$inhand_salary = ($gross_salary - $pf_employee);
} elseif (($total_salary < 15000) && ($salary_type === 'NO')) {
echo'hello';
$pf_company = 1200;
$pf_employee = 1200;
$percent = 0.62;
$gross_salary = ($total_salary - $pf_company);
$base_salary = ($percent * $gross_salary);
$HRA = ($base_salary / 2);
$others = ($gross_salary - ($base_salary + $HRA));
$inhand_salary = ($gross_salary - $pf_employee);
}
答案 0 :(得分:0)
尝试匹配大写条件,并检查条件中的空格。
strtoupper(trim($salary_type))
答案 1 :(得分:-1)
可能的第二个问题可能是:
当您在条件$salary_type ==='NO'
中检查数据类型时,在您声明的帖子中,您正在传递$ salary_type = NO。它似乎不是一个字符串类型。
请尝试从条件中删除一个=或将NO作为字符串传递以验证条件