Created
September 10, 2012 19:01
-
-
Save phpfiddle/3692995 to your computer and use it in GitHub Desktop.
Using file socket to read a page
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 | |
/** | |
* Using file socket to read a page | |
* Sample from internet | |
*/ | |
$fp = fsockopen ("slashdot.org", 80); | |
if ($fp) | |
{ | |
fwrite($fp, "GET / HTTP/1.1\r\nHOST: slashdot.org\r\n\r\n"); | |
while (!feof($fp)) | |
{ | |
highlight_string(fread($fp,256)); | |
} | |
fclose ($fp); | |
} else | |
{ | |
print "Fatal error\n"; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Phpfiddle.org sample file