EventHttp::setDefaultCallback

(PECL event >= 1.4.0-beta)

EventHttp::setDefaultCallbackSets default callback to handle requests that are not caught by specific callbacks

说明

public EventHttp::setDefaultCallback ( string $cb [, string $arg ] ) : void

Sets default callback to handle requests that are not caught by specific callbacks

参数

cb

The callback callable . It should match the following prototype:

callback ([ EventHttpRequest $req = NULL [, mixed $arg = NULL ]] ) : void

req

EventHttpRequest object.

arg

Custom data.

arg

User custom data passed to the callback.

返回值

Returns TRUE on success. Otherwise FALSE.

范例

Example #1 EventHttp::setDefaultCallback() example

<?php
$base 
= new EventBase();
$http = new EventHttp($base);

$socket socket_create(AF_INETSOCK_STREAMSOL_TCP);

if (!
$http->bind("127.0.0.1"8088)) {
    exit(
"bind(1) failed\n");
};

$http->setDefaultCallback(function($req) {
    echo 
"URI: "$req->getUri(), PHP_EOL;
    
$req->sendReply(200"OK");
});

$base->dispatch();
?>

参见

相关文章
php domnode checks if the specified namespaceuri is the default namespace or notphp eventhttp sets the what http methods are supported in requests accepted by this server and passed to user callbacksphp eventhttp sets a callback for specified uriphp eventhttp sets default callback to handle requests that are not caught by specific callbacksphp eventhttp sets maximum http header sizephp eventhttp sets the timeout for an http requestphp eio 函数 returns number of not yet handled requestsphp eio 函数 can be to be called whenever there are pending requests that need finishingphp fdf 函数 sets fdf specific output headersphp gupnp 函数 sets up callback for variable change notificationphp oci8 函数 returns the next child statement resource from a parent statement resource that has oracle database 12c implicit result setsphp sqlite 函数 opens a persistent handle to an sqlite database and create the database if it does not existphp sqlite 函数 execute a query that does not prefetch and buffer all dataphp gettext 函数 sets the default domainphp gmagick sets the object s default compression qualityphp imagick sets the image bias for any method that convolves an imagephp mongocursorinterface checks if there are results that have not yet been sent from the databasephp soapserver sets the class which handles soap requestsphp soapserver sets the object which will be used to handle soap requestsphp solrquery sets the number of rows to display in each group expand.rows . server default 5
关注编程学问公众号