Re: continuation in PHP?

From: Date: Sat, 13 Oct 2001 13:52:26 +0000
Subject: Re: continuation in PHP?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-70978@lists.php.net to get a copy of this message
I don't know why you need this, but it needs some work-around. You should declare every important variable as static inisde your function and keep an additional variable (or pass it with the arguments) which indicates where the execution starts from. <?php function continuation() { static $myvar1; static $myvar2; static $return = 0; $args = func_get_args(); switch($return) { case 0: $myvar1 = $args[0]; $return = 0; return; case 1: $myvar2 = $args[0]; $return = 2; return 1; case 2: if ($myvar1 > $myvar2) return min($myvar1, $myvar2); else return FALSE; } } ?> ----- Original Message ----- From: "Steven Haryanto" <steven@haryan.to> To: <php-general@lists.php.net> Sent: Saturday, October 13, 2001 3:10 PM Subject: [PHP] continuation in PHP? > can we implement continuation in the current version of PHP? i > would like to be able to return from a function and then later > on resume the function at the point where i last returned (say, > in the middle of a loop inside the function). > > -- > sh > > > -- > 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 >

« previous php.general (#70978) next »