How can the file_get_contents function in PHP be used to retrieve webpage content?

The file_get_contents function in PHP can be used to retrieve webpage content by passing the URL of the webpage as a parameter. This function will return the content of the webpage as a string, which can then be processed or displayed as needed in your PHP code.

<?php
$url = "https://www.example.com";
$content = file_get_contents($url);

if($content === false){
    echo "Failed to retrieve webpage content.";
} else {
    echo $content;
}
?>