Why can't my PHP log file be fully text?

I am trying to debug a Wordpress installation with a bloated plugin; so I added a very simple homegrown logger that records all callbacks, which are mostly listed in one, ultimately, in a 250mm multidimensional Wordpress array (I can't use print_r()it because I need to catch them right before they are called).

My log line $logger->log("\t" . $callback . "\n");

The logger creates a dandy text file in normal situations, but at two points during this particular task it adds something, which is why my log file is no longer properly encoded. Gedit (I'm on Ubuntu) will not open the file, stating that it did not understand the encoding. In vim, the guilty corrupt callback (which I could not find in the debugger looking at the array) is in the middle and is printed as ^@lambda_546, and at the end of the file there is this nice guy ^M. ^Mand ^@are blue in my vim that doesn't have a color theme for files .txt. I do not know what it means.

I tried to add a condition is_string($callback), but I get the same results.

Any ideas?

+3
source share
3

. . PHP create_function, , , : chr(0) . lambda_n. PHP.

\r. , . - , , \r\n.

0

^@ NUL (\0), ^M CR (\r). , . , . geany , .

+1

, .

0

Source: https://habr.com/ru/post/1745179/


All Articles