rondog Posted June 24, 2010 Share Posted June 24, 2010 I come from an actionscripting background so I am curious as to why this does not work in PHP? <?php $test = "testvar"; function runMe() { echo $test; //--- returns an undefined variable error } runMe(); ?> How would I go about making $test available to the runMe() method without passing it into the method itself? Link to comment https://forums.phpfreaks.com/topic/205793-simple-explanation-needed-for-this/ Share on other sites More sharing options...
premiso Posted June 24, 2010 Share Posted June 24, 2010 http://www.php.net/manual/en/language.variables.scope.php Variable Scope is what you want to read up on. Link to comment https://forums.phpfreaks.com/topic/205793-simple-explanation-needed-for-this/#findComment-1076898 Share on other sites More sharing options...
rondog Posted June 24, 2010 Author Share Posted June 24, 2010 excellent, thanks Link to comment https://forums.phpfreaks.com/topic/205793-simple-explanation-needed-for-this/#findComment-1076918 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.