the posted code contains a php syntax error (a closing ?> tag inside the function definition) and doesn't run at all, so that's not the actual code producing that error.
a few possibilities why the function definition is not present in the current program scope -
the function definition is inside of a conditional statement, and so isn't defined until the code where that statements is at has been executed and the conditional statement is true.
the function definition is inside of another function definition, and so isn't defined until the parent function has been called.
the function definition is being required (you should use require for things your program just have) using a url, not a file system path, and is not in the same instance of your program as the function call.
after you correct the php syntax error, the posted code produces an undefined constant error because the function call is before the point where the constants are defined.
it would take seeing the actual code producing the error to help with what is wrong with it.