In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "php json_encode how to remove backslashes", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let Xiaobian take you to learn "php json_encode how to remove backslashes"!
php json_encode Do not backslash implementation method: 1, use PHP's own parameter "JSON_UNESCAPED_SLASHES";2, by "str_replace("\\/", "/", json_encode($url));" replacement.
Operating environment: Windows 7 system, PHP7.1 version, DELL G3 computer
php json_encode Do not backslash how to achieve?
Resolves backslashes in json_encode formatted data
Make json_encode formatted data without backslashes
Problem Description:
When we return json format data to the front end or server, after converting with json_encode format, there will always be backslashes, and the default json_encode will escape/to\/, as follows:
"data":"http:\/\/www.****. com\/static\/admin\/upload\/1545030861.jpg"
What we want is the following format:
"data":"http://www.****. com/static/admin/upload/1545023021.jpg"
Solution:
1. Use PHP's built-in parameters: JSON_UNESCAPED_SLASHES
$url = 'http://www.chyblog.com/static/admin/upload/1545023021.jpg';echo json_encode($url,JSON_UNESCAPED_SLASHES);
2. You can also replace it directly.
$url = 'http://www.chyblog.com/static/admin/upload/1545023021.jpg';echo str_replace("\\/", "/", json_encode($url));
The result is the same!
At this point, I believe everyone has a deeper understanding of "php json_encode how to remove backslashes", so let's actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.