Re: Programming structures
| From: | David Newcomb | Date: | Mon, 26 Jun 2000 10:29:38 +0000 |
| Subject: | Re: Programming structures | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-3093@lists.php.net to get a copy of this message | ||
Is there some sort of atexit() type function like in 'C', where it calls a
list
of functions when the program exits?
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.