On Sat, 2003-08-16 at 18:28, Robert Cummings wrote: > > PHP then I think the option should be investigated. The current isset() > function fails many developers from what I can see, and I know I've > experienced this problem before, and so I think a more appropriate
Aaaah, I was just documenting some code when I came across where I ran into this problem... Let's say I have a configuration array of data for an object. The configuration array is initialized as follows: $this->settings = array ( 'name' => null, 'length' => null, 'width' => null, 'height' => null, ); Now I have generic "get" and "set" method for my object: function getData( $fieldName ) { if( isset( $this->settings[$fieldName] ) ) { return $fieldName; } $this->triggerWarning( 'Invalid data retrieval for class foo!' ); return null; } The set method works similarly, and here the null assignment to the array is valid since I want to generate an warning if the data is not explicitly set by the developer. It is true that I could set the value to -1 or some such other hack, or that I could use array_keys() and then check the values of the resulting array, but these are hacks for a perfectly valid use of the value null and in inadequate isset() function. Now I'm sure many will argue that I should have individual "get" and "set" methods for every data entry, but really, that shouldn't be necessary (and let's be honest this follows a similar style to the ini_get() function), and this method is much more versatile and easy to maintain, not to mention I'm sure it reduces processing overhead. Anyways I think I've said enough on this topic so i guess we'll see how things go :) Cheers, Rob. -- .---------------------------------------------. | Worlds of Carnage - http://www.wocmud.org | :---------------------------------------------: | Come visit a world of myth and legend where | | fantastical creatures come to life and the | | stuff of nightmares grasp for your soul. | `---------------------------------------------' -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php