php file_get_contents($url) return strange string

Try to do this from Curl i have post some code that will help you

<?php

  if( isset( $_POST['site_url'] ) && !empty( $_POST['site_url'] ) ){
    echo get_html($_POST['site_url']);
  } else {
echo 'false';
  }

  function get_html($url) {
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
   }

  ?>

get website url from your html form this is html how to set

<div class="col-md-offset-2 col-md-8">
            <form role="form" id="siteform" method="post">
                <div class="form-group">
                    <input type="url" class="form-control" name="site_url" id="site_url" placeholder="Enter your site address">
                    <span class="help-block"></span>
                </div>
                <button data-loading-text="Please wait..." type="submit" id="url_getter" class="btn btn-default btn-success">Submit</button>
            </form>
        </div>
    </div>

Leave a Comment