PHP tricks

php PHP
<?php
ini_set('error_reporting', E_ALL); // or error_reporting(E_ALL);
ini_set('display_error', 1); // enable error

ignore_user_abort(true); // Disable script die on client close connexion
set_time_limit(0); // Disable timeout

header('Content-Type: text/plain');
header('Connection: Keep-Alive');
header('X-Content-Type-Options: nosniff'); // Permit chunks

ob_start(); // Start buffer (no send data)
echo $_SERVER['REQUEST_SCHEME']?? 'http'.'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']."\n"; // Current URL
ob_clean(); // Clean buffer (remove all buffer data)
echo $_SERVER['REMOTE_ADDR']."\n"; // Client IP address
ob_end_flush(); // Flush buffer (send buffer and clean is)

echo shell_exec('ls -a'); // Execute command

while (true) {
  ob_end_flush(); // Flush buffer and stop it for send data
  echo "msg\n"; // Add data to buffer
  usleep(40000); // Wait small time
  ob_start(); // Start buffer
}
127.0.0.1
.
..
tricks.php
msg
msg
msg
msg
msg
msg
msg
msg
msg
...