Starting out with PHP sockets
Posted: Sun May 30, 2004 1:03 pm
Since last night I decided to take on the task of socket programming in PHP. To start out I planned to attempt to grab the source of my webpage and print the contents to the screen. Its very basic I know, but it will give me a rough idea on how sockets actually communicate. So far I have this:
<?php
$host = "www.mysite.com";
$HTTP = "GET $host";
$Source = fsockopen($host,80);
echo $Source;
fclose($Source);
?>
But all i get is resource ID#2 or something along those lines. I know I have to send a GET request at port 80 in order to get the source but my method doesn't work. Any help appreciated!
Regards
Joe
<?php
$host = "www.mysite.com";
$HTTP = "GET $host";
$Source = fsockopen($host,80);
echo $Source;
fclose($Source);
?>
But all i get is resource ID#2 or something along those lines. I know I have to send a GET request at port 80 in order to get the source but my method doesn't work. Any help appreciated!
Regards
Joe