使用php转义输出HTML到JavaScript_php教程-查字典教程网
使用php转义输出HTML到JavaScript
使用php转义输出HTML到JavaScript
发布时间:2016-12-29 来源:查字典编辑
摘要:最近在做天地图是GIS集成··要输出HTML到JavaScript里面··涉及到代码转义什么的比较麻烦··所以写个PHP的function分...

最近在做天地图是GIS集成··要输出HTML到JavaScript里面··涉及到代码转义什么的比较麻烦··所以写个PHP的function

分享一下:

function jsformat($str) { $str = trim($str); $str = str_replace('ss', '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; }

使用就不用说了··就是直接调用jsformat($str)

以上所述就是本文的全部内容了,希望能对大家理解php转义到javascript有所帮助

请您花一点时间将文章分享给您的朋友或者留下评论。我们将会由衷感谢您的支持!

相关阅读
推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
  • 大家都在看
  • 小编推荐
  • 猜你喜欢
  • 最新php教程学习
    热门php教程学习
    编程开发子分类