PHP 8.6.0 Beta 3 is available for testing

Yar_Client::call

(PECL yar >= 1.0.0)

Yar_Client::callCall 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