What are the potential pitfalls of calling a function from a different file in PHP using $_GET[]?
When calling a function from a different file in PHP using $_GET[], there are potential security risks such as allowing users to execute arbitrary functions or access sensitive data. To mitigate these risks, it is important to validate and sanitize the input received through $_GET[] before using it to call a function. This can be done by checking if the function exists and restricting the functions that can be called.
if(isset($_GET['function']) && function_exists($_GET['function']) && in_array($_GET['function'], ['function1', 'function2'])) {
$functionName = $_GET['function'];
$functionName();
} else {
echo "Invalid function call.";
}