Home >Backend Development >PHP Tutorial >Detailed introduction to php hessian_PHP tutorial
What is hessian?
When I saw this word, I didn’t know how to pronounce it. The phonetic symbol is [hes] pronounced Heisen.
Hessian is a lightweight remote data exchange tool that provides the function of RMI (remote method invocation) using a simple method. Compared with webservice, hessian is simpler and faster. The binary rpc protocol is used. Because it is a binary protocol, it is very suitable for sending binary data
hessian is language independent.
2. How to use it in the php tutorial?
Do you think this can be used just like soap by opening one in php.ini? I think so too. Yes
What I'm here to tell you is that it's wrong to think so.
You need to download a hessianphp library to use.
Download address http://hessianphp.sourceforge.net/
3. See how to use it.
1. Server side.
Copy the code. The code is as follows:
include_once('hessianphp/dist/hessianservice.php');
class helloworldservice
{
public function __construct()
{
}
public function add($a, $b)
{
return $a+$b;
}
}
$wrapper = new hessianservice();
$wrapper->registerobject(new helloworldservice);
$wrapper->displayinfo = true;
$wrapper->service();
?>
Server side results
2. Client
Copy the code. The code is as follows:
require_once 'hessianphp/dist/hessianclient.php';
hessian::errorreporting(hessian_silent);
$url = 'http://localhost/info.php';
$proxy = & new hessianclient($url);
$sum = $proxy->add(3, 5);
echo $sum;
if(hessian::error()) {
$errors = hessian::error();
print_r($erros->message);
//var_dump($errors);
}
?>
client results