Chapter 6 _ PHP array (2)

Source: Internet
Author: User

This article summarizes the predefined array variables. With predefined array variables, we can obtain information such as the system environment, user dialogs, and form data.

1. SERVER variable: $ _ SERVER

Use the foreach statement to print all elements in $ _ SERVER:

 <?     (   =>           .' => '..'<br>'  ?>

2. environment variable: $ _ ENV(No output results)

3. GET variable: $ _ GET

<Form action = "<? ['Php _ SELF ']?> "Method =" GET "> name: <input type =" text "name =" name "size =" 15 "/> age: <input type = "text" name = "age" size = "15"/> Hobbies: <input type = "text" name = "Hober" size = "15"/> <input type = "submit" name = "submit" value = "submit"/> </ form> <? (['Submit ''<p>'' name :'. ['name']. '<br> ''age :'. ['age']. '<br> ''Hobbies :'. ['hobby']. '<br>'?>

4. POST variable: $ _ POST

When data is transmitted through POST, the data is not displayed in the URL, so it is safer than GET. Furthermore, there is no theoretical limit on the amount of data transmitted in POST mode.

<Form action = "<? ['Php _ SELF ']?> "Method =" POST "> name: <input type =" text "name =" name "size =" 15 "/> age: <input type = "text" name = "age" size = "15"/> Hobbies: <input type = "text" name = "Hober" size = "15"/> <input type = "submit" name = "submit" value = "submit"/> </ form> <? (['Submit ''<p>'' name :'. ['name']. '<br> ''age :'. ['age']. '<br> ''Hobbies :'. ['hobby']. '<br>'?>

5. File Upload variable: $ _ FILES(The Error Code indicates that the file cannot be found)

<Form enctype = "multipart/form-data" action = "<? = ['Php _ SELF ']?> "Method =" POST "> <input type =" hidden "name =" MAX_FILE_SIZE "value =" 104857600 "/> <! -- 100 M --> upload a file: <input name = "upload_file" type = "file" size = "50"/> <input type = "submit" name = "submit" value = "Upload"/> </ form> <? (['Submit '['uplaod _ file'] ['error'] = UPLOAD_ERR_ OK? 'Upload successful! <Br> ':' Upload Failed! <Br> ''upload file name :'. ['upload _ file'] ['name']. '<br> ''size of the uploaded file :'. ['upload _ file'] ['SIZE']. 'byte <br> ''temporary file name :'. ['upload _ file'] ['tmp _ name']. '<br>'?>

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.