Skip to content

Instantly share code, notes, and snippets.

@microweber
Created July 27, 2012 06:15
Show Gist options
  • Save microweber/3186437 to your computer and use it in GitHub Desktop.
Save microweber/3186437 to your computer and use it in GitHub Desktop.
php background tasks
<?php
ignore_user_abort();
set_time_limit(0);
ob_start(); // This is required
include 'somefile.php';
echo $someString;
$content_size = ob_get_length();
$content = ob_get_contents();
ob_end_clean();
header( 'Content-Length: ' . $content_size );
header( 'Connection: close' );
echo $content;
flush();
// The browser should no longer show the page loading bar and should
// consider the page fully loaded. Nothing else that you output will
// be displayed to the user
echo "I'm never seen!";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment