php字符串转义像python的“”“ ""&QUOT ;? [英] php string escaping like python's """ """?

查看:238
本文介绍了php字符串转义像python的“”“ ""&QUOT ;?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有一个简单的方法来逃避php中的字符串。



在python中我使用,并且之间的所有内容都被转义。所以当使用特殊字符时,它将被忽略。



我有一些文本可以回显,并手动转义一切都会永远。


$ b $ php有内置的类似函数吗?



谢谢!

解决方案

你有哪些角色逃避?



您可以使用 单引号 [docs] 。在这样的字符串中必须转义的唯一字符是 \ '



如果你有一个长字符串,还可以看一下 $ b。 $ b

Hi I was wondering if there is an easy way to escape strings in php.

In python I use """ """, and everything between there is escaped. so when using special characters it is ignored.

I have some text to echo, and escaping everything manually just takes forever.

Does php have a similar function built in ?

thanks!

解决方案

Which are the characters do you have to escape?

You could use single quotes [docs]. The only characters that have to be escaped in such a string are \ and '.

If you have a long string, also have a look at heredoc [docs].

这篇关于php字符串转义像python的“”“ ""&QUOT ;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆