Use phprpc for Ajax Secure Login

Source: Internet
Author: User
Tags php server php source code

Introduction: This is a detailed page for Ajax secure login using phprpc. It introduces PHP, related knowledge, skills, experience, and some PHP source code.

Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 362311 'rolling = 'no'>

Phprpc is a lightweight, secure, cross-Internet, cross-language, cross-platform, cross-environment, cross-domain, support for transmission of complex objects, support for parameter reference, and support high-performance remote process call protocol that supports content output redirection, hierarchical error processing, session-oriented, and service-oriented.

Unlike other Ajax frameworks, phprpc follows the"Only do one thing and do it well. It is only responsible for data transmission, and will be the best transmission! It makes it easy for you to do things that were previously impossible or difficult to do with the traditional Ajax method!

I believe that one of the main reasons why many people choose phprpc is that it makes it easier for you to develop Ajax applications! Although the power of phprpc is not limited to this, I have to admit that this is indeed a highlight of phprpc!
So, let's take a look at how to use phprpc 3.0 to compile Ajax applications.

 

The following is a simple example (or even a boring example) to illustrate how to use phprpc 3.0 to write Ajax applications. This example shows how the MVC pattern mentioned above works. Here we will take the PHP server as an example. The first example is simple. The client inputs a string and the server calculates its sha1 value.

<? PHP require_once (".. /PHP/phprpc_server.php "); $ Server = new phprpc_server (); $ server-> Add (" sha1 "); $ server-> Start ();?>

There are only four simple linesCodeThe built-in PHP sha1 function is released. Now, the client can directly use this function.

<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <HTML xmlns = "http://www.w3.org/1999/xhtml">  

This example is very simple, and there are only two statements related to phprpc. One is:

VaR RPC = new phprpc_client ('sha1. php', ['sha1']);

This statement is used to create a phprpc_client object. The first parameter is the server address. The relative path or absolute path can be used here.

And this path can be cross-origin! Therefore, you can use cross-Origin applications!

The second parameter is the list of server-side function names that you need to use. Therefore, although we only have one function, we also need to write it as an array. In this way, we have a client object that can call the server method.

How can we call it? Let's look at the second statement about phprpc:

 
Rpc. sha1 (input, showresult );

This statement is quite simple. You will find that we use the function name published on the server side as a method for calling the RPC object. Its first parameter is the value of the sha1 function. The second parameter is a function, which is a callback function. That is to say, after the server method is executed, the function is automatically called to process the result. It is defined previously. You will find that it has a parameter result, which is the return value of sha1 in our remote process. It is passed through this parameter of the callback function.

Official: http://www.phprpc.org/zh_CN/

Love J2EE follow Java Michael Jackson video station JSON online tools

Http://biancheng.dnbcw.info/php/362311.html pageno: 1.

Related Article

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.