On Wed, 2009-05-06 at 08:43 -0400, Tom Worster wrote:
> On 5/6/09 6:56 AM, "Marcus Gnaß" <gona...@gmx.de> wrote:
> > Tom Worster wrote:
> >> there's a control structure i wish php had: a simple block that you can
> >> break out of, e.g.
> > 
> > As Maarten pointed out you could use a function. Another alternative is
> > to use Exceptions which might be the most proper way to do it.
> in a thread off-list i commented on the use of a function. here's what i
> said:
> yes, it's just like that. i could wrap a function around the logic. and
> sometimes i use that trick.
> the downside to that is access to globals. for many of my scripts there's a
> common pattern:
> 1 get set up.
> 2 process inputs, checking and preparing data for use 3 and 4 or aborting to
> an error handler at the end of this section (which is what the breaks all
> jump to) if there's a problem with the input.
> 3 do some work
> 4 prepare an output page
> in this scheme, it's convenient if 2, 3 and 4 all have access to the same
> namespace, so i don't usually use the function approach.

Then create a shared namespace...

$GLOBALS['myWhateverWorksNamespace']['varName'] = 'varValue';

Application and Templating Framework for PHP

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to