Skip to content

Instantly share code, notes, and snippets.

@up1
Last active August 29, 2015 14:08
Show Gist options
  • Save up1/6b92ecec460ab424631a to your computer and use it in GitHub Desktop.
Save up1/6b92ecec460ab424631a to your computer and use it in GitHub Desktop.
Demo :: php router
function logAccess($status = 200) {
file_put_contents("php://stdout", sprintf("custom =>[%s] %s:%s [%s]: %sn",
date("D M j H:i:s Y"), $_SERVER["REMOTE_ADDR"],
$_SERVER["REMOTE_PORT"], $status, $_SERVER["REQUEST_URI"]));
}
//Run server
$php -S localhost:8888 -t . router.php
# Output #
[Tue Nov 4 19:49:36 2014] ::1:49619 [200]: /
custom =>[Tue Nov 4 12:49:45 2014] ::1:49620 [404]: /fffn[Tue Nov 4 19:49:56 2014] ::1:49621 Invalid request (Unexpected EOF)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment