Jump to content

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


OM2

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.