Sending variables between 2 functions

#2
[eluser]xwero[/eluser]
That is some bad example code Smile

If you have methods (functions) in a class you can do
Code:
class Someclass
{
   var $foo;

   function a()
   {
      $this->foo = 1
      $this->b();
   }

   function b()
   {
      if(is_numeric($this->foo))
      {
          return $this->foo + 1;
      }
      else
      {
          return 10;
      }
   }
}

if it are separate functions you can only pass values by using parameters. You could use a global but that is bad practice.


Messages In This Thread
Sending variables between 2 functions - by El Forum - 04-03-2008, 02:53 AM
Sending variables between 2 functions - by El Forum - 04-03-2008, 03:18 AM
Sending variables between 2 functions - by El Forum - 04-03-2008, 03:58 AM
Sending variables between 2 functions - by El Forum - 04-03-2008, 04:08 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.