-
In action. php, you only need to use the extract () function to unbind the $ _ POST global data: action. php
- Extract ($ _ POST );
- // Equivalent to $ username = $ _ POST ['username'];
- // $ Password = $ _ POST ['password'];
- ?>
Explanation in the php manual:
Extract (PHP 4, PHP 5)
Extract-import the variable from the array to the current symbol table
Int extract (array $ var_array [, int $ extract_type [, string $ prefix])
This function is used to import variables from the array to the current symbol table. The array var_array is used as the parameter and the key name is used as the variable name, and the value is used as the variable value. Each key/value pair will create a variable in the current symbol table and be affected by the extract_type and prefix parameters.
Note: This function returns the number of extracted variables from version 4.0.5.
Note: EXTR_IF_EXISTS and EXTR_PREFIX_IF_EXISTS are introduced in version 4.2.0.
Note: EXTR_REFS is introduced in version 4.3.0.
Extract () checks each key name to see if it can be used as a valid variable name. it also checks for conflicts with existing variable names in the symbol table. The method for dealing with illegal/numbers and conflicting key names is determined by the extract_type parameter. It can be one of the following values:
- /* Assume that $ var_array is the array returned by wddx_deserialize */
- $ Size = "large ";
- $ Var_array = array ("color" => "blue ",
- "Size" => "medium ",
- "Shape" => "sphere ");
- Extract ($ var_array, EXTR_PREFIX_SAME, "wddx ");
- Echo "$ color, $ size, $ shape, $ wddx_size \ n ";
- ?>
Output in the previous example: blue, large, sphere, medium
$ Size is not overwritten. because EXTR_PREFIX_SAME is specified, $ wddx_size is created. If EXTR_SKIP is specified, $ wddx_size is not created. EXTR_OVERWRITE sets the value of $ size to "medium", and EXTR_PREFIX_ALL creates a new variable $ wddx_color, $ wddx_size, and $ wddx_shape.
The associated array must be used. the array of the numeric index will not produce results unless EXTR_PREFIX_ALL or EXTR_PREFIX_INVALID is used. |