PHP 8.6.0 Beta 3 is available for testing

Yar_Client::call

(PECL yar >= 1.0.0)

Yar_Client::callCall a remote service

Beschreibung

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.

Parameter-Liste

method

The name of the remote service method.

arguments

The list of arguments passed to the remote method.

Rückgabewerte

Returns the return value of the remote service method.

Fehler/Exceptions

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.

Beispiele

Beispiel #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)));
?>

Das oben gezeigte Beispiel erzeugt eine ähnliche Ausgabe wie:

int(3)
int(3)
...

Siehe auch

add a note

User Contributed Notes

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