NULL character found in serialized string

I cannot unserialize() return line so that I serialize() 'd and is saved in a text file. I also can not copy-paste the line, it only copies the data to NULL, so I can not initialize it to PHP.

Here is a short excerpt from what it looks like in Notepad ++

enter image description here

Any ideas on how to non-sterilize this?

Note. I am using error_log($backtrace, 3, 'file.log'); to save the file, and then just open in Notepad ++ for copy-paste, but I can not copy the NULL character behind it.

+4
source share
1 answer

Thus, the serialize function identifies member variables with the null * null syntax, as you show here.

The null character is encoded in the string as \0 and is usually not displayed on the output. For non-serialization, you will need to convert this “null” text back to \0 .

When I write a serialized array, I run it through a function that converts \0 to [NULL] .

 $string = str_replace("\0","[NULL]",$string); 

Then, when you are ready for non-socialization, you can just do the opposite

 $string = str_replace("[NULL]","\0",$string); 
+2
source

All Articles