-
-
Save n1shantshrivastava/10018000 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function http_file_get_contents( $url ) { | |
$response = file_get_contents( $url ); | |
return $response; | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function http_fopen( $url ) { | |
$params = array( | |
'http' => array( | |
'method' => 'GET' | |
) | |
); | |
$ctx = stream_context_create($params); | |
$fp = @fopen( $url, 'rb', false, $ctx); | |
$response = ''; | |
while( is_resource( $fp ) && | |
$fp && | |
!feof( $fp ) ) { | |
$response .= fread( $fp , 1024); | |
} | |
fclose($fp); | |
return $response; | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function http_fsockopen( $url ) | |
{ | |
$parts=parse_url($url); | |
$fp = fsockopen($parts['host'], | |
isset($parts['port'])?$parts['port']:80, | |
$errno, $errstr, 30); | |
$path = ( isset( $parts['path'] )? $parts['path'] : '/' ); | |
$out = "GET ". $path ." HTTP/1.1\r\n"; | |
$out.= "Host: ".$parts['host']."\r\n"; | |
$out.= "Connection: Close\r\n\r\n"; | |
fwrite($fp, $out); | |
$response = ''; | |
while( is_resource( $fp ) && | |
$fp && | |
!feof( $fp ) ) { | |
$response .= fread( $fp , 1024); | |
} | |
fclose($fp); | |
return $response; | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
error_reporting(E_ALL); | |
ini_set("display_errors", 1); | |
require_once( 'http_fopen.php' ); | |
require_once( 'http_fsockopen.php' ); | |
require_once( 'http_file_get_contents.php' ); | |
$url = 'http://www.leggetter.co.uk'; | |
// $response = http_fopen( $url ); | |
$response = http_fsockopen( $url ); | |
//$response = http_file_get_contents( $url ); | |
echo( $response ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment