Re: Globally accessible objects without using 'global $obj;'
| From: | Greg Beaver | Date: | Sat, 13 Nov 2004 02:26:33 +0000 |
| Subject: | Re: Globally accessible objects without using 'global $obj;' | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-201888@lists.php.net to get a copy of this message | ||
Chris W. Parker wrote:
What I'd ultimately like to do is be able to return more than just a true/false from a function regarding it's end state. For example, a function could fail for multiple reasons and just returning a plain false for all situations does not suffice.You could either return an object like PEAR_Error (http://pear.php.net/manual/en/core.pear.pear-error.php) or use a more customizable solution like PEAR_ErrorStack (http://pear.php.net/manual/en/core.pear.pear-errorstack.php). Also, don't forget about built-in options like trigger_error and Exceptions in php5. More important than what you use is planning for future growth. Your applications will get larger. It may seem like a time-saver to do a quickie fix that requires less initial typing, but I guarantee you will run into a brick wall when you do have to change things and be forced to rewrite everything - not exactly a timesaver, unless you simply give up on making your code better :) Greg