Re: Best Practices: Toggle Item In Element
Check the example at http://www.php.net/manual/en/function.empty.php#id7108863 Basically isset() checks whether a variable has been set at all, no matter the value, while empty() considers the following all to mean empty: (an empty string) 0 (0 as an integer) 0 (0 as a string) NULL FALSE array() (an empty array) var $var; (a variable declared, but without a value in a class) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Best Practices: Toggle Item In Element
One mistake - isset() also returns false if the variable is set to null. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Best Practices: Toggle Item In Element
Actually both seemed to work for me. Thanks to you both. Anyone know the difference, out of curiousity? On Mar 12, 8:49 am, jmn2k1 [EMAIL PROTECTED] wrote: I guess this gives the same error, bc the index is still undefined, so you should try with isset() On Mar 9, 9:30 am, jitka [EMAIL PROTECTED] wrote: if (!empty($data['ticker'])) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Best Practices: Toggle Item In Element
I guess this gives the same error, bc the index is still undefined, so you should try with isset() On Mar 9, 9:30 am, jitka [EMAIL PROTECTED] wrote: if (!empty($data['ticker'])) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Best Practices: Toggle Item In Element
if (!empty($data['ticker'])) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Best Practices: Toggle Item In Element
Ok so I have a bunch of views, called by different controllers that each reference the same element 'post'. Each controller passes a set of parameters to the element via the renderElement('post', $data) method. All the parameters are passed through $data and all is peachy. However, ONE of the views has a special little parameter called 'ticker' passed through $data['ticker']. In my view I have set $data['ticker'] = 1 to indicate that the little ticker should be shown in the element only for this one view! In my 'post' element I say: if ($data['ticker']){ // show that ticker!!! } Problem is that for ALL the other controllers-views I get a 'missing index' for ticker. So, what I am asking is what is the best php5 / cake practice for handling this. I would rather not have to define $data['ticker'] in every other view or anywhere else. Is there a way to define it in the element and then overwrite it on load (or something). I am trying to determine the best, most agile practice for this situation. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---