Php outputs the http address in the database and the format changes. // changes to/. how can this problem be solved?

Source: Internet
Author: User
Php outputs the http address in the database and the format changes. how can this problem be solved? I know that we can use str_replace to replace \ With '', but this will also cause problems, if the data in json format contains Chinese characters, the \ asd5 of Chinese characters will be changed to asd5 .. Is there any other way to solve this problem?


Reply to discussion (solution)

Why/becomes \/. have you found the reason?
/Is not a special character. without a php function, it will be escaped (except preg_quote)

You can use str_replace to replace \/'/'....

Why/becomes \/. have you found the reason?
/Is not a special character. without a php function, it will be escaped (except preg_quote)



I don't know why .. Store it in the database. This is the case ..

You didn't do it. that's impossible.

You didn't do it. that's impossible.


function get_js_array($sql){$result = @mysql_query($sql) or die(mysql_error());$arr = array();while($row = @mysql_fetch_array($result, MYSQL_ASSOC)){$arr[] = $row;  }$js = json_encode($arr);mysql_free_result($result);return $js;}


This is my execution statement .. I don't know. Is there a problem?

Oh! This is the case.

$js = json_encode($arr, JSON_UNESCAPED_SLASHES);

Oh! This is the case.

$js = json_encode($arr, JSON_UNESCAPED_SLASHES);


Perfect solution .. Like!

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.