Simple use of PHPRPC

WBOY
Release: 2016-08-08 09:26:36
Original
1269 people have browsed it

PHPRPC is a lightweight, secure, cross-internet, cross-language, cross-platform, cross-environment, cross-domain, supports complex object transmission, supports reference parameter passing, supports content output redirection, and supports A hierarchical error-handling, session-enabled, service-oriented, high-performance remote procedure call protocol. To learn more please visit http://www.phprpc.com.

Click the link above to download the php version from the official website, and unzip the compressed package to the root directory of the website (mine is phprpc). Create two test files server.php and client.php in the root directory.

server.php code:

<?php
    include ("php/phprpc_server.php");
    
    $server = new PHPRPC_Server();
    $server->add('HelloWorld');
    $server->start();

<pre name="code" class="php">    function HelloWorld() {
        return 'Hello World!';
    }
Copy after login
?>
Copy after login

client.php code:

<?php
    include ("php/phprpc_client.php");
    $client = new PHPRPC_Client(&#39;http://localhost/server.php&#39;);
    echo $client->HelloWorld();
?>
Copy after login
uses a browser to access http://127.0.0.1/client.php, and "Hello World!" is output normally. If there is an error like the one below, the reason is that when PHPRPC mode is enabled after version 5.4, PHP already contains the gzdecode() function, and the gzdecode() function defined by the developer will conflict with it. Solution: Open phprpccompat.php, find function gzdecode($data, &$filename = '', &$error = '', $maxlength = null) on line 72 (there may be differences), use this function as follows Just include the code.

if (! function_exists('gzdecode')) {
    //将gzdecode函数包括进来
}
Copy after login

The above has introduced the simple use of PHPRPC, including aspects of the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!