RE: [PHP] Multiple function return question
| From: | Paul Maine | Date: | Sun, 15 Sep 2002 12:47:59 +0000 |
| Subject: | RE: [PHP] Multiple function return question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-116435@lists.php.net to get a copy of this message | ||
That's what I thought. When I execute the following command, it doesn't
return to the immediate funxtion that called it. $pfpro is a C executable
that is passed a number of parameters. Any ideas are greatly appreciated.
$command = "$pfpro $host $port \"$args\" $timeout";
$result =
$command;
-----Original Message-----
From: Matt [mailto:mschroebel@epooch.com]
Sent: Sunday, September 15, 2002 7:13 AM
To: Paul Maine; php-general@lists.php.net
Subject: Re: [PHP] Multiple function return question
> From: "Paul Maine" <pmaine@austin.rr.com>
> Sent: Sunday, September 15, 2002 8:10 AM
> Subject: [PHP] Multiple function return question
> I have a function that calls a function that in turns calls the last
> function. I want the last function that is called to return to the
function
> that called it. How do I do this in PHP?
Unless I misunderstand, that is exactly how functions work. Try it:
<?php
function c($var) {
echo "Entering function c: $var<br>\n";
$var += 1;
echo "Leaving function c: $var<br>\n";
return $var;
}
function b($var) {
echo "Entering function b: $var<br>\n";
$var += 1;
$var = c($var);
echo "Leaving function b: $var<br>\n";
return $var;
}
function a($var) {
echo "Entering function a: $var<br>\n";
$var += 1;
$var = b($var);
echo "Leaving function a: $var<br>\n";
$return $var;
}
$i = a(10);
echo "<br>Final value: $i<br>\n";
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php