PHP output string problems with more special characters
Want to use Echo to output the following string
A:4:{s:8: "collects"; A:0:{}s:8: "Comments"; a:0:{}
Echo ' A:4:{s:8: "collects"; A:0:{}s:8: "Comments"; a:0:{} ';
It's definitely not going to work.
Special characters to be specially handled, because the string to be output and more than one sentence, good trouble Ah,,
We have a tool or software that is not easy to use, and so on, I can directly input a string of strings, can be generated immediately under the echo can be directly code
------Solution--------------------
Echo << <>
A:4:{s:8: "collects"; A:0:{}s:8: "Comments"; a:0:{}. More content
EOF;
------Solution--------------------
It's not serialized.
PHP Code
unserialize-The value description of PHP created from the stored representation mixed unserialize (string $str [, String $callback]) Unserialize () operates on a single serialized variable and turns it Change the value of PHP back. Returns the converted value, which can be an integer, float, string, array, or object. Returns FALSE if the passed string is not serializable. Note:unserialize_callback_func instructions If you need to instantiate an undefined class while the deserialization is being serialized, you can set the callback function to be called (to avoid getting an incomplete object "__php_incomplete_class"). ' Unserialize_callback_func ' can be defined by php.ini, Ini_set (), or. htaccess. It is called every time a undefined class is instantiated. To disable this feature, simply empty the setting. It is also important to note that the UNSERIALIZE_CALLBACK_FUNC directive is available from the beginning of PHP 4.2.0. The Note:callback parameter is an object that is added to the PHP 4.2.0 if the deserialized variable is, and after the object is successfully reconstructed, PHP automatically attempts to invoke the __wakeup () member function (if one exists). Example #1 Unserialize_callback_func Example
Note: In PHP 3, the method is not saved when serializing an object. PHP 4 Breaks This limitation while preserving properties and methods. See the serialization Objects section of classes and objects for more information. Example #2 unserialize () example
See Serialize (). serialize-produces a stored value that describes the description string serialize (mixed $value) serialize () returns a string that contains a byte stream representing value that can be stored anywhere. This facilitates the storage or delivery of PHP values without losing their type and structure. To change the serialized string back to PHP's value, use Unserialize (). Serialize () can handle any type except resource. You can even serialize () those arrays that contain pointers to their own references. The references in the array/object you are serialize () will also be stored. When serializing an object, PHP will attempt to call the object's member function __sleep () before the sequence action. This allows the object to do any cleanup before it is serialized. Similarly, when you use Unserialize () to restore an object, the __wakeup () member function is called. Note: In PHP 3, the object properties will be serialized, but the method will be lost. PHP 4 Breaks This limit and can store properties and methods at the same time. See the serialization Objects section of classes and objects for more information. Example #1 Serialize () example