PHP Tricks

Home / Coding Tricks / PHP Tricks

Date & Time Formatting

date("F j, Y")

Output: July 14, 2016

date("Y-m-d")

Output: 2016-07-21

date("H:i:s")

Output: 13:45:22

date("h:i:s a")

Output: 01:45:22 pm

Open Errors

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

Flushing Technique

public function flushStart () {
      
  ob_end_clean();
  header("Connection: close");
  ignore_user_abort();
  ob_start();
      
}
    
public function flushEnd () {
      
  $size = ob_get_length();
  header("Content-Length: $size");
  ob_end_flush();
  flush();
      
}

Memory Limit

ini_set('memory_limit', '256M');

Compression

ob_start('ob_gzhandler');

Leave a Reply

Your email address will not be published. Required fields are marked *