Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Is the php $GLOBALS associative array over written in WordPress with the WordPress $GLOBALS? I have a piece of code that uses $GLOBALS['myvariablename'] to access a global variable. It works in php, but stops working when I bring the code to a WordPress environment.

Is there a way to use $GLOBALS associative array? Or should I absolutely declare variables global before getting them in functions and using them?

Added Later:

My code: http://bharath.lohray.com/sources/redditGetVotes.phps

I am trying to use the reddit API to fetch and display the popularity of my links on my wordpress blog. The global variables are for configuration information - like the reddit user name etc. I have documented my steps in my post here.

share|improve this question
    
You shouldn't use $Globals at all, but where and how are you placing this global? –  Wyck Oct 6 '13 at 16:58
    
Post your code, please. globals are best avoided if possible, but for what it is worth I have not noticed any real issue with them if you understand how they work. –  s_ha_dum Oct 6 '13 at 17:07
    
@s_ha_dum: Updated question. My Code is at bharath.lohray.com/sources/redditGetVotes.phps It is workign for now, but I cannot use $GLOBALS['variableName'] as an associative array. –  Lord Loh. Oct 6 '13 at 22:08
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.