只需检查是否$ _POST [ 'com_fee']存在,是数字,并且如果是> = 0
//$commm = $_POST['com_fee'];
$commm_list = [ '',
'kjhgfd',
'jhgf-dcfvgb',
'-',
'-1',
'0',
'+1',
];
function from_stf($commm) {
$findme = '-';
$pos = strpos($commm, $findme);
if ($pos === false) {
$comfee= 'Fee';
} else{$comfee='Commission';}
return $comfee;
}
foreach ($commm_list as $commm) {
$res = from_stf($commm);
print $commm.' --> '.$res."\n";
}
和结果:
$ php ./wiksphp/new.php
--> Fee
kjhgfd --> Fee
jhgf-dcfvgb --> Commission
- --> Commission
-1 --> Commission
0 --> Fee
+1 --> Fee
$
如果小于零,则数字为负数。 – FirstOne
这似乎不可复制。 – FirstOne
请编辑您的问题以在'if'语句之前包含'var_dump($ pos,$ comm,$ findme,$ _POST);'的输出。 – Progman