What is better when return false |
Hello when using return false I would also like to know if return "" is OK
Or which one is better over the other. PHP Code: public function getattachments($where_column = '', $id = '')
There's only one rule - please don't tell anyone to go and read the manual. Sometimes the manual just SUCKS!
(06-29-2017, 07:42 PM)wolfgang1983 Wrote: Hello when using return false I would also like to know if return "" is OK Return an empty array.
(06-29-2017, 08:15 PM)Paradinight Wrote:(06-29-2017, 07:42 PM)wolfgang1983 Wrote: Hello when using return false I would also like to know if return "" is OK Something like return array();
There's only one rule - please don't tell anyone to go and read the manual. Sometimes the manual just SUCKS!
(06-29-2017, 09:17 PM)wolfgang1983 Wrote:(06-29-2017, 08:15 PM)Paradinight Wrote:(06-29-2017, 07:42 PM)wolfgang1983 Wrote: Hello when using return false I would also like to know if return "" is OK yes or PHP Code: return $query->result_array(); without $query->num_rows() ![]()
Yes that's what I do as well
if the success case would return an array then i would return an empty array if success would return a string then an empty return string That way the return value is consistent
On the package it said needs Windows 7 or better. So I installed Linux.
Hope you decided to return NULL.
Returning an empty array when there are no results is not the same as returning an array with known keys. You'll have to validate the array before you can actually use it. PHP Code: if(NULL !== ($attachments = $model->getAttachments())) : PHP Code: if (!empty($array)) empty is great for arrays, but very bad for using on strings "0". What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
|
Welcome Guest, Not a member yet? Register Sign In |