Is the file() function in PHP equivalent to visiting a page in a browser, and what are the implications for server load?

The file() function in PHP is not equivalent to visiting a page in a browser. It is used to read a file into an array. However, if the file being read is a URL, it will fetch the contents of that URL. This can potentially increase server load if used excessively, as it will make a request to the specified URL each time it is called.

// Example code snippet to read a URL using file() function
$url = 'https://www.example.com';
$data = file($url);
foreach ($data as $line) {
    echo $line;
}