Skip to content

Instantly share code, notes, and snippets.

@axgle
Created October 22, 2018 10:51
Show Gist options
  • Save axgle/fb5b945bacc24fcb5bce0e2cddce218c to your computer and use it in GitHub Desktop.
Save axgle/fb5b945bacc24fcb5bce0e2cddce218c to your computer and use it in GitHub Desktop.
<?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