What are some alternatives to dynamically executing PHP functions at runtime without restarting the application?

When dynamically executing PHP functions at runtime, the use of `eval()` or `call_user_func()` can be risky and may introduce security vulnerabilities. An alternative approach is to use a mapping of function names to callable functions, allowing you to dynamically call functions without using `eval()` or `call_user_func()`. This can provide a safer and more maintainable solution.

// Define an array mapping function names to callable functions
$functionMap = [
    'function1' => function() {
        // Function 1 logic here
    },
    'function2' => function() {
        // Function 2 logic here
    },
    // Add more functions as needed
];

// Dynamically call a function based on a key
$functionKey = 'function1';
if (array_key_exists($functionKey, $functionMap)) {
    $functionMap[$functionKey]();
} else {
    // Handle error for undefined function
}