Re: Programming structures
| From: | thies at digicol dot de | Date: | Mon, 26 Jun 2000 10:34:36 +0000 |
| Subject: | Re: Programming structures | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-3094@lists.php.net to get a copy of this message | ||
On Mon, Jun 26, 2000 at 11:29:38AM +0100, David Newcomb wrote:
>
> Is there some sort of atexit() type function like in 'C', where it calls a
> list
> of functions when the program exits?
register_shutdown_function() is your friend.
tc
>
> David.
>
> ----- Original Message -----
> From: alex <alex@quad.com.ar>
> To: <php-general@lists.php.net>
> Sent: Sunday, June 25, 2000 12:38 AM
> Subject: [PHP-GENERAL] Programming structures
>
>
> > I'm trying to figure out what's the best way to structure all my code and
> I
> > have some doubts about it.. here are some thoughts:
> > When it comes to handling errors I usually do one of the following:
> >
> > <?
> > $foo = my_function();
> > if (!$foo){
> > echo "some text explaining the problem";
> > } else {
> > ... rest of the code....
> > }
> > ?>
> >
> > or just:
> >
> > <?
> > $foo = my_function() or die("some text explaining the problem");
> > ?>
> >
> > I would allways use the die() alternative, since it's much more readable
> > than the "if/else" solution. On the other hand, making your script die is
> > not so nice, for example I usually require() some footer.inc's at the end
> of
> > the scripts that wouldn't get executed with the die() before it. That's
> why
> > I mostly use the "if/else" structure for handling errors. My problem comes
> > when I have to nest lots of if/else structures in the code, it becomes a
> lot
> > more complicated to read.
> >
> > Are there other better alternatives than the ones I've showed up in the
> > examples above?
> > What's your prefered way to handle that kind of problems?
> >
> > any hints would be great!
> >
> > Alex V.
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
--
Thies C. Arntzen "One Big-Mac, Small Fries and a Coke!"
Digital Collections Phone +49 40 235350 Fax +49 40 23535180
Hammerbrookstr. 93 20097 Hamburg / Germany