2010-11-21 6 views
0

이 코드에 문제가 있습니다. 필드 customer_note이 비어 있으면 필드에 텍스트가있는 경우 NY의 값을 반환해야합니다. 결과는 Y 또는 N이 XML 행으로 전달됩니다. PHP 5.2.9를 사용하고 있습니다.PHP "if empty"도움 Joomla - VirtueMart

감사합니다. 빈 값 간주되는 볼

< ?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; 
?> 
+2

값을 "return"? 표시되는 코드가 매우 불완전한 것 같습니다. –

+0

'Y'또는 'N'이 무엇입니까? 코드가 귀하의 질문과 관련이 있습니까? 구체적인 질문/문제는 무엇입니까? – KingCrunch

답변

0

는 잘 모르겠어요.

strlen을 사용할 수도 있습니다.

$has_customer_note = strlen($customer_note) > 0 ? 'Y' : 'N'; 
0
$has_customer_note = empty($customer_note) ? 'N' : 'Y'; 

체크 아웃 empty의 반환 값에 대한 부분을 : 당신이 원하는 경우

if(!empty($customer_note)) { 
    $shopper_message .= $customer_note."\n"; 
} else { 
    $shopper_message .= "\n"; 
}