Is there any advantage to conditionally defining functions in PHP? For example, if I have a script similar to this
function abc() {
...
}
function xyz() {
...
}
if (user_is_logged_in()) {
...
abc();
...
xyz();
}
else echo 'Not logged in.';
Would there be any advantage, and would it be legal, to move those function definitions inside the if
statement? I don't know much about the back end of PHP, but it seems like the server could potentially have to do a lot of work defining the functions, and then have them never be used.