Jump to content

[SOLVED] Does it matter where I declare my variables?


Recommended Posts

Does it matter where I declare my variables?

 

I have some code where I declare variables (in an array) that will be used globally.

 

I have some code further below that I want to take out and put into another file.

This will help in readability and updating that code.

The code though, uses the global variables.

 

Now, out of a matter of habit, I like to put my include staments right at the top.

If I did this though: the code would access variables that are only declared below.

 

Hope that makes sense.

 

I know in a lot of languages: it doesn't matter.

Wasn't sure what the case was this PHP, so I thought I'd check.

 

Let me know.

 

Thanks.

 

 

OM

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.