Generally speaking, you cannot use a variable BEFORE you create it. I suspect you might need to rethink your logic (no offense).
1 top of page
2 do something here
3 do some more
4 use a variable here that has no value
5 do even more
6 and more
7 set a value to the variable
8 do some 'magic' (perhaps goto IF you have the right version of php)
you would end up all your repeating steps
Could you explain why you cannot set the variable value earlier?