PHP Conference Ehime 2026

Yar_Client::call

(PECL yar >= 1.0.0)

Yar_Client::callCall a remote service

Description

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.

Parameters

method

The name of the remote service method.

arguments

The list of arguments passed to the remote method.

Return Values

Returns the return value of the remote service method.

Errors/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.

Examples

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

The above example will output something similar to:

int(3)
int(3)
...

See Also

add a note

User Contributed Notes

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