gas-orm icon indicating copy to clipboard operation
gas-orm copied to clipboard

Issue with empty() and properties

Open koichirose opened this issue 11 years ago • 1 comments

I'm having trouble determining if an object has a property:

 if (!empty($deal->start_date)) {
echo $deal->start_date; //outputs nothing, does not enter the if
}

$start_date = $deal->start_date;

if (!empty($start_date)) {
echo $deal->start_date; //outputs the deal start date, enters the if
}  

What is going on?

koichirose avatar Nov 06 '13 10:11 koichirose

i never used Gas, but you can try with strlen() or similar eg.:

if (strlen($deal->start_date) > 0) {

    // your code here  ...

}

wallacesilva avatar Jun 08 '14 22:06 wallacesilva