PHP 8.4.26 Released!

Yar_Client::call

(PECL yar >= 1.0.0)

Yar_Client::call — Call a remote service

説明

public function Yar_Client::call(string $method, array $arguments): mixed

Issues an RPC call to the remote method method. This is exactly what happens when a non-existent method is invoked on a Yar_Client object (via PHP's __call magic method); Yar_Client::call() only exists so that remote methods literally named call or __call can still be reached.

パラメータ

method

The name of the remote service method.

arguments

The list of arguments passed to the remote method.

戻り値

Returns the return value of the remote service method.

エラー / 例外

When the remote method does not exist on the server, or is not public, the client throws a Yar_Client_Exception with the code YAR_ERR_REQUEST. See Yar_Client_Exception for the other client-side failures and their exception classes.

例

例1 Yar_Client::call() example

<?php
$client = new Yar_Client("http://api.example.com/operator.php");

/* The usual way: invoke the remote method as if it were local.
 * This is translated into call("add", array(1, 2)) behind the scenes. */
var_dump($client->add(1, 2));

/* Equivalent: call the method explicitly by name */
var_dump($client->call("add", array(1, 2)));

/* Needed only when the remote service literally exposes a method
 * named call (or __call), which the magic __call cannot reach */
var_dump($client->call("call", array($some_argument)));
?>

上の例の出力は、 たとえば以下のようになります。

int(3)
int(3)
...

参考

+add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top