略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: pht\Thread::addFileTask

2024-04-18

pht\Thread::addFileTask

(PECL pht >= 0.0.1)

pht\Thread::addFileTaskFile threading

说明

public pht\Thread::addFileTask ( string $fileName [, mixed $...globals ] ) : void

Adds a new file task to a pht\Threads internal task queue.

参数

func

The name of the file to be threaded.

...globals

An optional list of arguments for the file. These arguments will be placed into a $_THREAD superglobal, which will be made available inside of the threaded file. All arguments will be serialised (since they are being passed to another thread).

返回值

No return value.

范例

Example #1 Adding a new file task to a thread

<?php

use pht\Thread;

$thread = new Thread();

$thread->addFileTask('file.php'123);

$thread->start();
$thread->join();

file.php:

<?php

[$one$two$three] = $_THREAD;

var_dump($one$two$three);

以上例程会输出:

int(1)
int(2)
int(3)
add a note add a note

User Contributed Notes

There are no user contributed notes for this page.

官方地址:https://www.php.net/manual/en/pht-thread.addFileTask.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3