Function level constants - declared at the top of the function?
The two reasons for using a constant rather than hard-coding are for readability and so it can be easily found and changed later, right? So declare it where it's easiest to find it later. I usually find this to be at the beginning of a function, class, or file - again, no matter how large it makes sense.
source to share
I usually declare them as close to where I will be using them as possible.
The reason is that when I go through other people's code it is very awkward to jump up and down the file to understand what is going on. Therefore, I try to make it easier to work with others when writing code.
For a small (ish) function, the top of the function may increase readability (and thus clarity to others), so this rule is far from being etched in stone.
source to share
I put them at the beginning of the file, treating them as configuration throughout the class. Also, when coding with mouse only and no matter the location, your shiny IDE will let you know.
It's not something that you constantly change, if you don't enter your constant, code, try whatever you want when you refactor and make it permanent.
source to share