On 17/09/15 00:09, Rowan Collins wrote: >> That is better coding practice, but extract() is an equally >> >valid practice currently being used and that needs a different way of >> >handling if the elements exist. > I'm still not entirely sure what it is you need to "handle". > > What is the behaviour that you'd put in the if(! exists ()) block? More > particularly, what would you put there and not put in the if(! is_null()) > block, since if they're the same, then that's what if(! isset()) does, so > we're all good?
I'd answered that one, but it looks like it did not end up on the list. Pushing it again ... If the 'variable' exists but is NULL you create a default element of that name. If the 'variable' does not exist nothing gets created. So exists($checklist) { is_null($checklist) { create default/empty object(); } else { create populate odbject($checklist); } else { display code in place of object; } If $checklist is always +ve then one can use '0' in place of NULL, but when a 'default' value is difficult to define NULL fills the gap and in SQL that is well understood, and there is no reason that the is_null() check is not part of createobject function but hat is optional. I personally would stick with the $hash['checklist'] but others obviously prefer to loose the $hash once inside the 'object' and currently you end up CURRENTLY with isset($checklist) { createobject($checklist); } else { is_null($checklist) { createobject($checklist); } Styling element in place of object; } Assuming createobject also handles the NULL condition with a second is_null inside the function. exists simply streamlines this to exists($checklist) { createobject($checklist); // Null = empty or default object } else { Styling element in place of object; // !exists leaves out object, or has code to create one } -- Lester Caine - G8HFL ----------------------------- Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk Rainbow Digital Media - http://rainbowdigitalmedia.co.uk -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php