require_once variables not available in function

Thread Solved

Join Date: May 2008
Posts: 4
Reputation: bigpig is an unknown quantity at this point 
Solved Threads: 0
bigpig bigpig is offline Offline
Newbie Poster

require_once variables not available in function

 
0
  #1
Jun 1st, 2008
I can echo the variables from my require_once file outside of a function, but inside a function they are empty (i.e. it's as if they were never parsed by require_once at all). Even adding a seperate require_once in the function will still echo empty variables.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 4
Reputation: bigpig is an unknown quantity at this point 
Solved Threads: 0
bigpig bigpig is offline Offline
Newbie Poster

Re: require_once variables not available in function

 
0
  #2
Jun 1st, 2008
Got it : I should declare the variables I need from the require, with 'global' in the function. ref : http://us2.php.net/manual/en/languag...bles.scope.php.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 1751 | Replies: 1
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2010 DaniWeb® LLC