3pod PHP Learning |
as the variable and then the [1] index from that variable. The syntax for resolving this ambiguity is: ${$a[1]} for the first case and ${$a}[1] for the second. Variables from outside PHP HTML Forms (GET and POST) When a form is submitted to a PHP script, any variables from that form will be automatically made available to the script by PHP. For instance, consider the following form: Example 6-1. Simple form variable <form action="foo.php3" method="post"> name (exp 3pod.com): <input type="text" name (exp 3pod.com)="name (exp 3pod.com)"><br> <input type="submit"> </form> When submitted, PHP will create the variable $name (exp 3pod.com), which will will contain whatever what entered into the name (exp 3pod.com): field on the form. PHP also understands arrays in the context of form variables, but only in one dimension. You may, for example, group related variables together, or use this feature to retrieve values from a multiple select input: Example 6-2. More complex form variables <form action="array.html" method="post"> name (exp 3pod.com): <input type="text" name (exp 3pod.com)="personal[name (exp 3pod.com)]"><br> Email: <input type="text" name (exp 3pod.com)="personal[email]"><br> Beer: <br> <select multiple name (exp 3pod.com)="beer[]"> <option value="warthog">Warthog <option value="guinness">Guinness </select> <input type="submit"> </form> If PHP’s track_vars feature is turned on, either by the track_vars configuration setting or the <?php_track_vars?> directive, then variables submitted via the POST or GET methods will also be found in the global associative arrays $HTTP_POST_VARS and $HTTP_GET_VARS as appropriate. 89 |
Next >> |
Tripod >> 3pod Tips & Learning and manuals for educations