PHP“if empty”帮助Joomla-VirtueMart
我的代码有问题。如果字段customer_note为空,如果字段中有文本,则需要它返回一个值N和Y。结果Y或N被传递到XML行中。我使用的是PHP5.2.9 多谢各位PHP“if empty”帮助Joomla-VirtueMart,php,Php,我的代码有问题。如果字段customer_note为空,如果字段中有文本,则需要它返回一个值N和Y。结果Y或N被传递到XML行中。我使用的是PHP5.2.9 多谢各位 if( !empty( $customer_note )) { $shopper_message .= $customer_note."\n"; } else { $shopper_message .= "\n"; } 我不确定你是否想要这个: < ?php function check_ifempty($cus
if( !empty( $customer_note )) {
$shopper_message .= $customer_note."\n";
} else {
$shopper_message .= "\n";
}
我不确定你是否想要这个:
< ?php
function check_ifempty($customer_note)
{
if (empty($customer_note))
{
return "N";
}
else
{
return "Y";
}
}
?>
< ?php
$customer_note = $_POST["customer_note"];
$result = check_ifempty($customer_note);
$xml .= $result;
?>
请查看有关的返回值的部分,以查看什么被视为空值
另一种选择是使用
将值返回到何处?您显示的代码似乎很不完整Y或N是什么?代码是否与您的问题有关?你的具体问题是什么?
$has_customer_note = empty($customer_note) ? 'N' : 'Y';
$has_customer_note = strlen($customer_note) > 0 ? 'Y' : 'N';