Skip to content

Instantly share code, notes, and snippets.

@phpfiddle
Created September 10, 2012 19:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phpfiddle/3692995 to your computer and use it in GitHub Desktop.
Save phpfiddle/3692995 to your computer and use it in GitHub Desktop.
Using file socket to read a page
<?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";
}
?>
@phpfiddle
Copy link
Author

Phpfiddle.org sample file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment