Home >Backend Development >PHP Problem >How to convert php string to object

How to convert php string to object

藏色散人
藏色散人Original
2020-07-18 10:33:236865browse

PHP string conversion object method: first define a json string; then in "index.php", enter the code "print_r(json_decode($a));"; finally print out the string The converted json object is enough.

How to convert php string to object

json_encode(), used to convert strings or arrays into json objects.

php string conversion object:

1. First, open the php editor and create a new php file, for example: index.php, which defines each json character. string.

Recommended: "PHP Tutorial"

How to convert php string to object

2. In index.php, enter the code: print_r(json_decode($a ));.

How to convert php string to object

#3. The browser runs the index.php page, and the json object converted from this string will be printed out.

How to convert php string to object

The above is the detailed content of How to convert php string to object. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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