Skip to content

Instantly share code, notes, and snippets.

View covid-19-percentage.php
<?php
define('TIME_NOW', time());
define('DS', DIRECTORY_SEPARATOR);
define('BASE_PATH', strtr(__DIR__, '\\', '/'));
clearstatcache();
$pathimpl = function() {
return BASE_PATH . '/' . ltrim(strtr(implode(DS, func_get_args()), '\\', '/'), '/');
@RomanStone
RomanStone / PECL.Events.Server.example.php
Created May 8, 2019
PHP Events Simple Hello World Server Example
View PECL.Events.Server.example.php
<?php
$addr = '127.0.0.1';
$port = 10080;
$host = 'localhost';
function hello_world($args = array()) {
$OS = PHP_OS; //strtolower(substr(PHP_OS, 0, 3)) == 'win';
$phpversion = phpversion();
@RomanStone
RomanStone / PHPServer.example.php
Last active Apr 25, 2019
An example of pure PHP Server (non-block, socket_select)
View PHPServer.example.php
<?php
$addr = '127.0.0.1';
$port = 10080;
// Use: curl -vv "http://127.0.0.1:10080/"
// 0 prints dots in infinite response (on client's side), for concurrent test
// 1 close connection after server/client negotiation
@RomanStone
RomanStone / index.php
Last active Dec 20, 2020
Serving media files for A/Video Playback "pseudo chunked" transfer encoding
View index.php
<?php
ini_set('display_errors', 0);
ini_set('display_startup_errors', 0);
ini_set('html_errors', 0);
ini_set('output_buffering', 0);
ini_set('zlib.output_compression', 0);
ini_set('implicit_flush', 1);
ini_set('ignore_user_abort', 1);