How can the same origin policy of a browser impact accessing data from external sources in a PHP project?

The same origin policy of a browser restricts web pages from making requests to a different domain than the one it originated from. This can impact accessing data from external sources in a PHP project if the data is hosted on a different domain. One way to bypass this restriction is by using a server-side proxy in PHP to fetch the external data and then serve it to the client from the same domain.

<?php
$url = 'https://example.com/data';
$data = file_get_contents($url);

header('Content-Type: application/json');
echo $data;
?>