The difference between arrayserialize processing in the thinkphpconfig file is config. php defines a constant of the array type. to serialize the array serialize, you need to write 'error _ code' = & gt; serialize (array (& nbsp; what is the difference between array serialize processing in the & thinkphp config file?
Define a constant of the array type in config. php. if you need to serialize the array serialize, you need to write
'Error _ code' => serialize (array (
// Client Error 4xx
400 => 'bad request ',
401 => 'authorized ',
...
)),
In use
$ERROR_COEDE = unserialize(C("ERROR_CODE"));return $ERROR_COEDE[$code];
This is OK. ERROR_CODE also does not change.
In the second case, if the array content is large and needs to be extracted to an independent file, use
Require (dirname (_ FILE _). '/code. php ');
Load ERROR_CODE of code. php
You can also use unserialize for deserialization.
However, if you set
'Default _ filter' => 'htmlspecialchars ',
Pay attention to it. Because thinkph checks whether this configuration parameter exists and uses the function corresponding to this configuration to process the content of code. php, the obtained content is escaped by htmlspecialchars. For example, double quotation marks "are converted \".
Therefore, remove the escape characters and deserialize them. otherwise, false is returned.
$HTTP_CODE = stripslashes(ERROR_CODE); $ERROR_ARR = unserialize($HTTP_CODE);