phprpc的簡單使用

來源:互聯網
上載者:User

標籤:include   c++   對象   rpc服務   面向   重新導向   用戶端   org   產生   

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.伺服器端代碼

例如:

<?phpinclude(‘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();?>

用戶端:

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

功能類似的還有 Hprose for php 

phprpc的簡單使用

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.