首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

Yar_Client::setOpt

(PECL yar >= 1.0.0)

Yar_Client::setOpt — Set calling contexts

Description

代码语言:javascript
复制
public boolean Yar_Client::setOpt ( number $name , mixed $value )

Parameters

name

it can be: YAR_OPT_PACKAGER, YAR_OPT_PERSISTENT (Need server support), YAR_OPT_TIMEOUT, YAR_OPT_CONNECT_TIMEOUT YAR_OPT_HEADER (Since 2.0.4)

value

Return Values

Examples

Example #1 Yar_Client::setOpt() example

代码语言:javascript
复制
<?php

$cient?=?new?Yar_Client("http://host/api/");

//Set?timeout?to?1s
$client->SetOpt(YAR_OPT_CONNECT_TIMEOUT,?1000);

//Set?packager?to?JSON
$client->SetOpt(YAR_OPT_PACKAGER,?"json");

//Set?Custom?headers
$client->SetOpt(YAR_OPT_HEADER,?array("hr1:?val1",?"hd2:?val2"));

/*?call?remote?service?*/
$result?=?$client->some_method("parameter");
?>

The above example will output something similar to:

See Also

← Yar_Client::__construct

Yar_Concurrent_Client →

代码语言:txt
复制
 ? 1997–2017 The PHP Documentation Group

Licensed under the Creative Commons Attribution License v3.0 or later.

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com