异步脚本执行PHP

I need to execute a PHP script without blocking user interface.

Look this (light) example :

<?php
   echo "user see this";
   header("Location:otherpage.php");

        sleep(10);
        for($i=1; $i < 100000; $i++){
            $t = fopen("test.txt", "a+");
            fwrite($t, "$i
");
            fclose($t);
        }
?>

This example need too much time to been executed, how to make it asynchronous and redirect the user witout interface waiting ???

I found a script who made what I need, but I don't understand it :

    ignore_user_abort(true);
set_time_limit(0);

$strURL = "PUT YOUR REDIRCT HERE";
header("Location: $strURL", true);
header("Connection: close", true);
header("Content-Encoding: none
");
header("Content-Length: 0", true);

flush();
ob_flush();

session_write_close();

// Continue processing...

sleep(100);
exit;

Someone can explain ?