Re: PHP Brainteasers 2011
| From: | Daniel Brown | Date: | Mon, 23 May 2011 15:29:49 +0000 |
| Subject: | Re: PHP Brainteasers 2011 | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-313116@lists.php.net to get a copy of this message | ||
On Fri, May 20, 2011 at 12:55, Marc Guay <marc@jkcommunications.com> wrote:
> I imagine this one's been done before, but maybe not in the same way....
I believe it was, but not quite the same, you're right.
"If at first you don't succeed, try, try again."
Nice one, Marc.
> <?php
>
> $result = succeed();
>
> while (!$result){
> try{
> $result = succeed();
>
> }
> catch (Exception $e){
> echo $e;
> }
> }
> echo "hell yeah";
>
> function succeed(){
> $a = rand(1,2);
>
> switch($a){
> case 1:
> trigger_error('fml');
> break;
> case 2:
> return TRUE;
> break;
> }
> }
> ?>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
</Daniel P. Brown>
Network Infrastructure Manager
http://www.php.net/