zoukankan      html  css  js  c++  java
  • phprpc的简单使用

    PHPRPC 是一个轻型的、安全的、跨网际的、跨语言的、跨平台的、跨环境的、跨域的、支持复杂对象传输的、支持引用参数传递的、支持内容输出重定向的、支持分级错误处理的、支持会话的、面向服务的高性能远程过程调用协议。

    PHPRPC支持多种语言包括,ASP,PHP,JAVA,C++,JAVASCRIPT,PYTHON等。官网:http://phprpc.org/zh_cn/ 有时候访问不了!

    PHPRPC 分为服务端和客户端

    首先按照PHPRPC.

    1.下载phprpc for php 的安装安装包解压

    其中bigint.php、compat.php、phprpc.php、phprpc_date.php、xxtea.php 这些属于公共文件。不论是客户端还是服务器都需要有这些文件。

    phprpc_client.php,是客户端文件,在客户端php文件里只需要应用这个文件就可以了它会自动包含公共文件。

    dhparams、dhparams.php、phprpc_server.php 这三个是服务器端需要的文件。其中dh-params目录中包含的是加密传输时生成密钥的参数。dhparams.php用来读取dhparams目录中的类。phprpc_server.php是服务端文件,如果使用php发布PHPRPC服务,只需要包含着文件就可以了。公共文件和dhparams.php不需要单独包含。

    2.服务器端代码

    例如:

    <?php
    include('phprpc/phprpc_server.php');
    class hello{
        static function helloworld(){
            
            return 'hello world';   
        }
         static function helloworld2(){
            
             return 'hello world2';   
        } 
    }
    $server = new PHPRPC_Server();
    $server->add('helloworld','hello');
    $server->add('helloworld2','hello');
    $server->start();
    ?>

    客户端:

    <?php
    include('phprpc/phprpc_client.php');
    $client = new PHPRPC_Client('http://admin.com/13.php');
    echo  $client->helloworld();
    ?>

    功能类似的还有 Hprose for php 

  • 相关阅读:
    将Vim改造为强大的IDE
    Ubuntu首次开启root用户
    ssh-keygen实现免密码登陆
    Ubuntu下配置samba服务器实现文件共享
    Ubuntu下Apache+php+mysql网站架设详解
    IIS支持PHP
    详解C/C++预处理器
    学C++之感悟
    return *this和return this的区别
    const 的全面总结
  • 原文地址:https://www.cnblogs.com/phpshen/p/6135055.html
Copyright © 2011-2022 走看看