What are the differences between using cURL, exec, and system functions to call scripts in PHP?

When calling external scripts in PHP, there are multiple functions available such as cURL, exec, and system. cURL is typically used for making HTTP requests, exec is used to execute a command in the system shell, and system is similar to exec but also displays the output. The choice between these functions depends on the specific requirements of the script being called and the desired behavior.

// Using cURL to call an external script
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://example.com/script.php');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
curl_close($ch);
echo $output;

// Using exec to call an external script
$output = exec('php /path/to/script.php');
echo $output;

// Using system to call an external script
$output = system('php /path/to/script.php');
echo $output;