> -----Original Message----- > From: Kyle Babich [mailto:[EMAIL PROTECTED] > Sent: 02 July 2003 00:19 > > 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.
Possibilities: function hello($x) { print 'hello ' . $name; $x = 1; } function bye($x) { if ($x == 1) print 'x = 1'; else print 'x != 1'; } hello($y); bye($y); -------------- function hello() { print 'hello ' . $name; $x = 1; return $x; } function bye($x) { if ($x == 1) print 'x = 1'; else print 'x != 1'; } $y = hello(); bye($y); -------------- function hello() { global $x; print 'hello ' . $name; $x = 1; } function bye() { global $x; if ($x == 1) print 'x = 1'; else print 'x != 1'; } hello(); bye(); Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php