Examples of use of PHPRPC and error fatal Error:cannot Redeclare gzdecode () in D:\wamp\www\immoc\phprpc\compat.php processing

Source: Internet
Author: User

reading today, found phprpc this good stuff, so write down here to make notes.

PHPRPC is a lightweight, secure, cross-network, cross-lingual, cross-platform, cross-domain, cross-field, multi-tiered, support-enabled, service-oriented, high-performance remote procedure call protocol that supports the transfer of reference parameters, supports content output redirection, supports hierarchical error handling, and supports session.

: http://www.phprpc.org/zh_CN/download/This version can be used directly after decompression, wherein bigint.php, compat.php, phprpc_date.php, xxtea.php belong to the public file. These files are required both on the client and on the server side.
Phprpc_client.php is a client file, if you only need to use the client, then as long as there are those public files and this file can be used, when used, directly in your program contains phprpc_client.php, public files do not need to be included separately.
Dhparams, dhparams.php phprpc_server.php These three files are required on the server side. Where the Dhparams directory contains the parameters used to generate the key when the encryption is transmitted. Dhparams.php is the class used to read files in the Dhparams directory. Phprpc_server.php is the server side, if you want to use PHP to publish the PHPRPC service, only need to include this file. Both public files and dhparams.php do not need to be included separately.
PHP 4.3+, PHP 5, PHP 6
The client requires the socket extension to be turned on.
The server side needs to have IIS, Apache, lighttpd and so on Can run PHP program Web server.
If the server side requires the ability to encrypt the transfer, it must ensure that the session is configured correctly.

Example:

Server-side:

<?php
Include ("phprpc/phprpc_server.php");
Class Hello {
static function HelloWorld ()
{
Return ' Hello world! ';
}
}
$server = new Phprpc_server ();
$server->add (' HelloWorld ', ' hello ');
$server->start ();
?>

Client:

<?php
Include ("phprpc/phprpc_client.php");

The URL here is the server-side address
$client = new Phprpc_client ("http://127.0.0.1/immoc/phprpc_server.php");
echo $client->helloworld ();
?>

After running, there is a fatal Error:cannot redeclare gzdecode () in D:\wamp\www\immoc\phprpc\compat.php on line 182
Error.


This problem occurs because PHP has self-contained the Gzdecode () function after the 5.4 release, and the developer's own definition of the Gzdecode () function conflicts with it.

Knowing the cause of the error, it is very convenient to solve. On line 72nd of the. \phprpc\compat.php file (here, it may be different), find function Gzdecode ($data, & $filename = ', & $error = ', $maxlength = null), include this function in the following code:

if (! function_exists (' Gzdecode ')) {
Include the Gzdecode function in the
}

。 After doing this, run the program again and get the results we want:



Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Examples of use of PHPRPC and error fatal Error:cannot Redeclare gzdecode () in D:\wamp\www\immoc\phprpc\compat.php processing

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.