What does this function mean? Read and set the configuration items (the meaning of the comment here is read and set. I cannot figure out how to set and read it. thank you !!!) PHPcodefunctionC ($ namenull, $ valuenull) {static $ configarray (); configuration item if (is_null ($ name) {what does this function mean?
// Read and set the configuration items (the meaning of the comment here is read and set. I cannot figure out how to set and read it. thank you !!!)
PHP code
Function C ($ name = null, $ value = null) {static $ config = array (); // configuration item if (is_null ($ name) {return $ config ;} if (! Is_null ($ name) {if (is_string ($ name) {$ name = strtolower ($ name); if (is_null ($ value )) {return isset ($ config [$ name])? $ Config [$ name]: false;} $ config [$ name] = $ value;} elseif (is_array ($ name) {$ name = array_change_key_case ($ name, CASE_LOWER); $ config = array_merge ($ config, $ name );}}}
------ Solution --------------------
The trick is the use of static $ config. when it leaves the function scope, its value will not disappear, and the last value will be retained.
This makes it clear:
PHP code
C ("hello", "I say hello"); // a value of c (array ("a", "B ")); // The second value var_dump (c (); array (3) {["hello"] => string (11) "I say hello" [0] => string (1) "a" [1] => string (1) "B "}