国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Table of Contents
Defect analysis of ThinkPHP’s built-in jsonRPC, thinkphp’s built-in jsonrpc
Home Backend Development PHP Tutorial Defect analysis of ThinkPHP's built-in jsonRPC, thinkphp's built-in jsonrpc_PHP tutorial

Defect analysis of ThinkPHP's built-in jsonRPC, thinkphp's built-in jsonrpc_PHP tutorial

Jul 13, 2016 am 10:11 AM
json thinkphp

Defect analysis of ThinkPHP’s built-in jsonRPC, thinkphp’s built-in jsonrpc

This article analyzes the flaws of ThinkPHP’s built-in jsonRPC in more detail. Share it with everyone for your reference. The specific analysis is as follows:

I have been developing ios applications recently. To develop ios applications, of course you need to use a server. When using a server, you must use the remote call protocol. Because I have always used PHP to develop, so I chose thinkphp as the apache server of the framework.

As for the remote calling protocol, after thinking about it, I decided to use jsonRPC. It is relatively simple and convenient. I looked through the manual of thinkphp (version 3.2) and found that thinkphp still supports jsonRPC. This is good. You don’t have to write it yourself (of course) It’s not a hassle to write it yourself).

Simply use thinkphp as the client to call the thinkphp server-side interface, which is easy to use.

The next step is the android side. I just went online to find a package (android-json-rpc.jar) and called the interface, eh! It’s easy to use and it’s going very smoothly.

Next I switched to ios. I found an objc-JSONRpc project on github and used it to call the interface. It was not easy to use. It was normal. Maybe there was something wrong with the project I was looking for, so I changed to Demiurgic. -JSON-RPC is still not easy to use. I started to have doubts about the program. Because there was no problem in calling the web and android terminals, I focused on my ios program. Oh my god, it took me half a day. I just couldn't find the problem. I also used the ios side to call the jsp client interface provided by others, and there was no problem.

Later, I started to look at the jsonRPC module built into thinkphp. After constant debugging (various debugging, deleting code, and Dbug), I found this line of code:

Copy code The code is as follows:
$result = @call_user_func_array(array($object,$request['method']),$request[' params'])

I noticed that this function did not call_user_func_array, array, click on it to see the parameter description. Sure enough, $request['params'] must be an array type, not that the array is not recognized alive or dead. What is even more hateful is that thinkphp did not perform this parameter Strict verification, so I don’t know what’s wrong.

It will be easier to handle once you know the reason, just add verification in front.

Copy code The code is as follows:
if (is_array($request['params'])) {
$request['params'] = array_values($request['params']);
} else {
$request['params'] = array($request['params']);
}

This solves the problem perfectly.

I hope this article will be helpful to everyone’s PHP programming based on the ThinkPHP framework.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/929676.htmlTechArticleDefect analysis of ThinkPHP’s built-in jsonRPC, thinkphp’s built-in jsonrpc This article analyzes the defects of ThinkPHP’s built-in jsonRPC in more detail. Share it with everyone for your reference. The specific analysis is as follows: The most...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to run thinkphp project How to run thinkphp project Apr 09, 2024 pm 05:33 PM

To run the ThinkPHP project, you need to: install Composer; use Composer to create the project; enter the project directory and execute php bin/console serve; visit http://localhost:8000 to view the welcome page.

There are several versions of thinkphp There are several versions of thinkphp Apr 09, 2024 pm 06:09 PM

ThinkPHP has multiple versions designed for different PHP versions. Major versions include 3.2, 5.0, 5.1, and 6.0, while minor versions are used to fix bugs and provide new features. The latest stable version is ThinkPHP 6.0.16. When choosing a version, consider the PHP version, feature requirements, and community support. It is recommended to use the latest stable version for best performance and support.

How to run thinkphp How to run thinkphp Apr 09, 2024 pm 05:39 PM

Steps to run ThinkPHP Framework locally: Download and unzip ThinkPHP Framework to a local directory. Create a virtual host (optional) pointing to the ThinkPHP root directory. Configure database connection parameters. Start the web server. Initialize the ThinkPHP application. Access the ThinkPHP application URL and run it.

How to install thinkphp How to install thinkphp Apr 09, 2024 pm 05:42 PM

ThinkPHP installation steps: Prepare PHP, Composer, and MySQL environments. Create projects using Composer. Install the ThinkPHP framework and dependencies. Configure database connection. Generate application code. Launch the application and visit http://localhost:8000.

Performance optimization tips for converting PHP arrays to JSON Performance optimization tips for converting PHP arrays to JSON May 04, 2024 pm 06:15 PM

Performance optimization methods for converting PHP arrays to JSON include: using JSON extensions and the json_encode() function; adding the JSON_UNESCAPED_UNICODE option to avoid character escaping; using buffers to improve loop encoding performance; caching JSON encoding results; and considering using a third-party JSON encoding library.

How is the performance of thinkphp? How is the performance of thinkphp? Apr 09, 2024 pm 05:24 PM

ThinkPHP is a high-performance PHP framework with advantages such as caching mechanism, code optimization, parallel processing and database optimization. Official performance tests show that it can handle more than 10,000 requests per second and is widely used in large-scale websites and enterprise systems such as JD.com and Ctrip in actual applications.

How do annotations in the Jackson library control JSON serialization and deserialization? How do annotations in the Jackson library control JSON serialization and deserialization? May 06, 2024 pm 10:09 PM

Annotations in the Jackson library control JSON serialization and deserialization: Serialization: @JsonIgnore: Ignore the property @JsonProperty: Specify the name @JsonGetter: Use the get method @JsonSetter: Use the set method Deserialization: @JsonIgnoreProperties: Ignore the property @ JsonProperty: Specify name @JsonCreator: Use constructor @JsonDeserialize: Custom logic

How to save JSON data to database in Golang? How to save JSON data to database in Golang? Jun 06, 2024 am 11:24 AM

JSON data can be saved into a MySQL database by using the gjson library or the json.Unmarshal function. The gjson library provides convenience methods to parse JSON fields, and the json.Unmarshal function requires a target type pointer to unmarshal JSON data. Both methods require preparing SQL statements and performing insert operations to persist the data into the database.

See all articles