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 evwatcher sets new callback for the watcherphp eio 函数 can be to be called whenever there are pending requests that need finishingphp informix 函数 sets the default return value on a fetch rowphp mysqlnd qc 函数 sets the callback functions for a user defined procedural storage handlerphp oci8 函数 returns the next child statement resource from a parent statement resource that has oracle database 12c implicit result setsphp sqlite 函数 execute a query that does not prefetch and buffer all dataphp svn 函数 get a handle on a specific version of the repository rootphp gettext 函数 sets the default domainphp gmagick sets the object s default compression qualityphp imagick sets the object s default background colorphp 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 returns the maximum number of tokens to parse in each document field that is not stored with termvector supportphp solrquery sets the number of rows to display in each group expand.rows . server default 5
关注编程学问公众号