Reading Html from Any Url in PHP Php by Rajesh Kumar Sahanee - September 11, 2022September 11, 20220 Post Views: 1,183 Hello Friends, Today I am going to share very short and simple code which we can use to read html from any url in PHP. I am going to share two methods to achieve this, so let’s start without wasting time. Method 1 (Using file_get_contents) index.php PHP <?php $htmlData = file_get_contents("https://www.lipsum.com/"); echo $htmlData; ?> 1234 <?php $htmlData = file_get_contents("https://www.lipsum.com/");echo $htmlData;?> Method 2 (Using Curl) index.php PHP <?php $url = "https://www.lipsum.com/"; $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_BINARYTRANSFER, true); $output = curl_exec($ch); echo $output; ?> 12345678 <?php $url = "https://www.lipsum.com/";$ch = curl_init($url);curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);$output = curl_exec($ch);echo $output;?> Thanks friends Your queries & suggestions are welcome in comments section Please don’t forget to share if you find this helpful