Home > Backend Development > PHP Tutorial > search engine optimization implementation code for outputting escaped JavaScript code in PHP

search engine optimization implementation code for outputting escaped JavaScript code in PHP

WBOY
Release: 2016-07-29 08:44:54
Original
1044 people have browsed it

Share it:

Copy the code The code is as follows:


function jsformat($str)
{
$str = trim($str);
$str = str_replace('\s\s', '\ s', $str);
$str = str_replace(chr(10), '', $str);
$str = str_replace(chr(13), '', $str);
$str = str_replace(' ', '', $str);
$str = str_replace('\', '\\', $str);
$str = str_replace('"', '\"', $str);
$str = str_replace('\'', '\\'', $str);
$str = str_replace("'", "'", $str);
return $str;
}


Needless to say when using it Yes, just call jsformat($str) directly

The above introduces the implementation code of output escape JavaScript code in search engine optimization PHP, including the content of search engine optimization. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template