Created
October 22, 2018 10:51
-
-
Save axgle/fb5b945bacc24fcb5bce0e2cddce218c to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
//HTTP server xample: hello world with php | |
//php myhttp.php | |
//open http://localhost:7788/ | |
$h = stream_socket_server("tcp://0.0.0.0:7788"); | |
print_r($h); | |
while($fp = stream_socket_accept($h)){ | |
echo fread($fp,1023); | |
fwrite($fp,"HTTP/1.1 200 OK\r\n"); | |
fwrite($fp,"conent-type: text/htmlr\r\n"); | |
fwrite($fp,"\r\n"); | |
fwrite($fp, " | |
<h1>Hello world HTTP!</h1> | |
"); | |
fwrite($fp, "<hr>".date('Y-m-d H:i:s')); | |
fclose($fp); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment