I'm trying to debug a plugin-bloated Wordpress installation; so I've added a very simple homebrew logger that records all the callbacks, which are basically listed in a single, ultimately 250+ row multidimensional array in Wordpress (I can't use print_r()
because I need to catch them right before they are called).
My logger line is $logger->log("\t" . $callback . "\n");
The logger produces a dandy text file in normal situations, but at two points during this particular task it is adding something which causes my log file to no longer be encoded properly. Gedit (I'm on Ubuntu) won't open the file, claiming to not understand the encoding. In vim, the culprit corrupt callback (which I could not find in the debugger, looking at the array) is about in the middle and printed as ^@lambda_546
and at the end of file there's this cute guy ^M
. The ^M
and ^@
are blue in my vim, which has no color theme开发者_如何学编程 set for .txt
files. I don't know what it means.
I tried adding an is_string($callback)
condition, but I get the same results.
Any ideas?
^@
is a NUL character (\0
) and ^M
is a CR (\r
). No idea why they're being generated though. You'd have to muck through the source and database to find out. geany should be able to open the file easily enough though.
Seems these cute guys are a result of your callback formatting for windows.
Mystery over. One of the callbacks was an anonymous function. Investigating the PHP create_function
documentation, I saw that a commenter had noted that the created function has a name like so: chr(0) . lambda_n
. Thanks PHP.
As for the \r
. Well, that is more embarrassing. My logger reused some older code that I previously written which did end lines in \r\n
.
精彩评论