> Hey is there a way to spin off a thread in PHP to do some large amount of
> work that can communicate with the program via Session Variables??

No, the closest you have is a feature called ticks.  Here is an example:

    function foo($str) {
        static $i = 0;

        print "$str: $i<br>\n";
        $i++;
    }

    register_tick_function("foo", "count");

    declare (ticks = 6) {

        for($i=0; $i<20; $i++) {
            echo "$i<br>\n";
        }

    }

The magic is in the declare { ... } block of code.  You stick whatever you
want to periodically interrupt inside the declare block.  In this example
every 6 ticks the for loop inside the declare block will be interrupted
and the registered tick function (foo) will be called.  A tick can loosely
thought of as a simple PHP expression.  So, this for loop goes through 2
ticks for every iteration.  1 tick is the for() expression and 1 tick is
the echo expression.

The resulting output from the above program (try it) is then:

        0
        1
        2
        count: 0
        3
        4
        5
        count: 1
        6
        7
        8
        count: 2
        9
        10
        11
        count: 3
        12
        13
        14
        count: 4
        15
        16
        17
        count: 5
        18
        19
        count: 6

It's not multithreading, but it is a way to go and check on some
long-running non-blocking process every now and then.

-Rasmus


-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to