Any valid PHP code may appear inside a function, even other
functions and class
definitions.

Function names follow the same rules as other labels in PHP. A
valid function name starts with a letter or underscore, followed
by any number of letters, numbers, or underscores. As a regular
expression, it would be expressed thus:
[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*.

Note:
Recursive function/method calls with over 100-200 recursion levels can
smash the stack and cause a termination of the current script. Especially,
infinite recursion is considered a programming error.

Please be advised that the code block defining the function, within the function_exists() call, has to be executed for the function to get defined, whereas this is not the case for regular, unenclosed functions.

Meaning, if you write code like this:

<?php

do_function();

if (!function_exists('my_undefined')) { function my_undefined() { }}

function do_function() {my_undefined();}?>

..Then my_undefined will not be defined before the code in do_function calls it. Some people put their function sections below the regular executing code of the script. Making any of it 'pluggable' can then cause problems.

You can also call function from itself. For example, I want to reach the deepest value in multidimensional array and I call function from inside the very same function. In this example function behave as some meta-loop.