PHP Classes
Icontem

Subject: variable scope in fcns


  Search   All class groups All class groups   Latest entries Latest entries   Top 10 charts Top 10 charts   Newsletter Newsletter   Blog Blog   Forums Forums   Help FAQ Help FAQ  
  Login   Register  
Recommend this page to a friend!

      Top level forums  >  PHP Specialists  >  General  >  variable scope in fcns  
Subject:variable scope in fcns
Summary:How to access variables next level up in function calls
Messages:6
Author:Brian Read
Date:2008-10-24 15:53:44
Update:2008-11-04 04:20:43
 

  1. variable scope in fcns   Reply  
Picture of Brian Read
Brian Read
2008-10-24 15:53:44
I have this:

a = 23;
function level1()
{$a = 29;level2();echo "<p>".$a."</p>";
}
function level2()
{global $a;echo "<p>".$a."</p>";
}
level1();
echo("Hello, World!" );
?>

The "global" makes $a take on the value of 23, whereas i really need to get it to take on the value of 29.

Clearly this is a simple example of a problem i have which is more complex!

There are 5 replies in this thread, which are not being displayed.
Browsing this forum thread replies is available only to premium subscribers.


Go to the premium subscriptions page to learn how to become a premium subscriber and have full access to this forum.


 
  Advertise on this site Advertise on this site   Site map Site map   Statistics Statistics   Site tips Site tips   Privacy policy Privacy policy   Contact Contact  

For more information send a message to :
info at phpclasses dot org.
Copyright (c) Icontem 1999-2008 PHP Classes - PHP Class Scripts
  PHP Book Reviews - Reviews of books and other products