开发者

php unprintable strings

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 pri开发者_JAVA百科ntf. 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?


If your string has something like %d, it expects a parameter to replace that with. For example: (taken from the php docs)

$format = 'There are %d monkeys in the %s';
printf($format, $num, $location);

Try printing it with echo instead.


Use printf to format your string. Use print or echo if you just want to display a string as-is.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜