PHP Conference Japan 2024

Yar_Server_Exception::getType

(PECL yar >= 1.0.0)

Yar_Server_Exception::getType擷取例外的類型

說明

public Yar_Server_Exception::getType(): 字串

取得伺服器拋出的例外原始類型

參數

此函式沒有參數。

回傳值

字串

範例

範例 #1 Yar_Server_Exception::getType() 範例

//Server.php
<?php
class Custom_Exception extends Exception {};

class
API {
public function
throw_exception($name) {
throw new
Custom_Exception($name);
}
}

$service = new Yar_Server(new API());
$service->handle();
?>

//Client.php
<?php
$client
= new Yar_Client("http://host/api.php");

try {
$client->throw_exception("client");
} catch (
Yar_Server_Exception $e) {
var_dump($e->getType());
var_dump($e->getMessage());
}

以上範例會輸出類似以下的內容

string(16) "Custom_Exception"
string(6) "client"

另請參閱

新增註釋

使用者貢獻的註釋

此頁面沒有使用者貢獻的註釋。
To Top