php无法打印的字符串
我的文本字符串在打印时表现得很奇怪。它们都来自在 DOMDocuments 的帮助下解析网站。我使用 DOMNode::nodeValue 来获取解析的文本。
我的大部分字符串都不能用 printf 打印。相反,我收到一条警告消息“警告:printf():参数太少”。 我尝试在字符串上使用 var_dump ,它们都包含字符串字符。有些被 var_dump 识别为字符串,但它们也不可打印。应该说,我相当猜测 var_dump 将它们识别为字符串,因为字符串(字符串的长度)是在转储字符之前打印的。 是否有某种字符可能会导致这种行为,导致我的字符串被解释为其他内容?
My text strings behaves very strange when printing them. They all come from parsing a website with help of DOMDocuments. I have used DOMNode::nodeValue
to get the parsed texts.
Most of my string is not printable with printf. Instead I get a warningmessage "Warning: printf(): Too few arguments ".
I've tried to use var_dump on the strings and they all contain string characters. Some are recognized by var_dump as strings, but they are not printable either. Should say that I'm rather guessing that var_dump recognizes them as strings since string(length of string) is printed before the dumped characters.
Is there some sort of characters that could cause this behaviour that causes my strings to be interpreted as something else?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您的字符串具有类似
%d
的内容,则它需要一个参数来替换它。例如:(取自 php 文档)尝试使用 < 打印它代码>回显代替。
If your string has something like
%d
, it expects a parameter to replace that with. For example: (taken from the php docs)Try printing it with
echo
instead.使用
printf
格式化字符串。如果您只想按原样显示字符串,请使用print
或echo
。Use
printf
to format your string. Useprint
orecho
if you just want to display a string as-is.