What are some common security risks associated with using file_get_contents in PHP?

Using file_get_contents in PHP can pose security risks such as allowing remote file inclusion attacks or exposing sensitive information if the input is not properly sanitized. To mitigate these risks, it is recommended to use the cURL extension in PHP, which provides more control and security features when making HTTP requests.

$url = 'https://example.com/data.json';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl);
curl_close($curl);

if ($response === false) {
    // Handle error
} else {
    // Process the response
}