Hprose for PHP

Source: Internet
Author: User

Directly convert all hprose for PHP files (hprosecommon. PHP, hproseio. PHP, hprosehttpserver. PHP and hprosehttpclient. directly copy to the directory of your development environment without any installation steps.
CreateHproseOfHelloServer
It is very easy to create a PHP hprose server. Next we will take the Linux environment as an example to explain. Assume that the Web server (Apache, Lighttpd, or any other HTTP server) has been configured in Linux, and PHP can be executed.ProgramAnd the publishing path is/var/www. Then we create an hprose directory under the release directory and put several hprose for PHP files in this directory. Create a helloserver. php file in the release directory. The content is as follows:

PHPCode

    1. <? PHP

    2. Include("Hprose/hprosehttpserver. php ");

    3. FunctionHello ($ name ){

    4. Return"Hello". $ name;

    5. }

    6. $ Server =NewHprosehttpserver ();

    7. $ Server-> addfunction ("hello ");

    8. $ Server-> handle ();

    9. ?>

In this way, our server has been created. Is it quite simple?
Let's take a look at the effect. Open the browser and enter the following url: http: // localhost/helloserver. php. Then press Enter. If the following page is displayed, our service is successfully released.

Next, let's take a look at how to create a client.
CreateHproseOfHelloClient
It is easier to create the PHP hprose client. The helloclient. php file is also created in the release directory. The content is as follows:

PHPCode

    1. <? PHP

    2. Include("Hprose/hprosehttpclient. php ");

    3. $ Client =NewHprosehttpclient ("http: // localhost/helloserver. php ");

    4. Echo $ client-> Hello ("hprose ");

    5. ?>

Enter http: // localhost/helloclient. php In the browser, or enter PHP helloclient. php In the command line. If the following result is displayed:

Reference

Hello hprose

It indicates that the client has been created successfully!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.