Re: have some free time?
| From: | Shena Delian O'Brien | Date: | Wed, 02 Jul 2003 00:04:25 +0000 |
| Subject: | Re: have some free time? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-153638@lists.php.net to get a copy of this message | ||
You need to return $x out of the function.
So do this:
function hello() {
print 'hello ' . $name;
$x = 1;
return ($x);
}
etc
Then call it assigned to a variable:
$x = hello();
echo $x;
bye();
Kyle Babich wrote:
I think this is short example of my problem... <?php $name = 'kyle'; function hello() {print 'hello ' . $name; $x = 1;} function bye() {if ($x == 1) print 'x = 1'; else print 'x != 1';} hello(); bye(); ?> Right now this returns: hello x != 1 What do I have to do to get bye() to return 'x = 1'? I tried declaring the x = 1 in hello() global and I tried declaring it static. On Tue, 01 Jul 2003 17:27:48 -0500, "Kyle Babich" <php@kyle.sent.com> said:Any php programmers out there have a little free time? I've been trying to find the bug in my logging system forever and I've all but given up. If anyone else wants to try their luck then... http://babich.us/log/source/log.php.txt http://babich.us/log/source/config.inc.php.txt http://babich.us/log/source/test.php.txt http://babich.us/log/source/clearLogs.inc.php.txt http://babich.us/log/source/logIpData.inc.php.txt http://babich.us/log/source/logAgentData.inc.php.txt http://babich.us/log/source/logLangData.inc.php.txt I have a feeling that it is an obvious, simple error that I am missing. Anyway, back to the bug hunting... -- Kyle -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php