Php study notes [pre-defined array (ultra-Global Array)]

Source: Internet
Author: User
Php learning notes pre-defined array (ultra-global array). For more information, see.

Php learning notes pre-defined array (ultra-global array). For more information, see.

  1.  
  2.  
  3. /* Pre-defined array:
  4. * Automatic global variable --- Super Global Array
  5. *
  6. * 1. contains data from WEB servers, clients, runtime environments, and user input.
  7. * 2. These arrays are special.
  8. * 3. These arrays can be used directly if they take effect automatically within the global range.
  9. * 4. users cannot customize these arrays, but these arrays are operated in the same way as their own arrays.
  10. * 5. You can directly use these arrays in functions.
  11. *
  12. * $ _ GET // variable submitted to the script through URL request
  13. * $ _ POST // variables submitted to the script through the http post method
  14. * $ _ REQUEST // variables submitted to the script through GET, POST, and COOKIE mechanisms
  15. * $ _ FILES // variables submitted to the script by uploading FILES via the http post method
  16. * $ _ COOKIE
  17. * $ _ SESSION
  18. * $ _ ENV // variables submitted to the script in the execution environment
  19. * $ _ SERVER // The variable is set by the web server or directly associated with the execution environment of the current script.
  20. * $ GLOBALS // as long as the variables are valid for the current script, the array key name is the name of the global script.
  21. *
  22. *
  23. */
  24. // The Super Global array can be directly called within the function.
  25. $ Arr = array (10, 20); // A general array
  26. $ _ GET = array (50, 90); // A Super Global array
  27. Function demo (){
  28. Global $ arr; // you must include
  29. Print_r ($ arr );
  30. Print_r ($ _ GET); // You do not need to include a directly called ultra-global array.
  31. }
  32. ?>
  33.  
  34. // Directly use the passed value as a variable, which is useful when register_global = on is in the php. ini configuration file.
  35. Echo $ username ."
    ";
  36. Echo $ email ."
    ";
  37. Echo $ page ."
    ";
  38. // The most stable value method
  39. Echo $ _ GET ["username"]."
    ";
  40. Echo $ _ GET ["email"]."
    ";
  41. Echo $ _ GET ["page"]."
    ";
  42. ?>
  43. "Demo. php? Username = zhangsan & email = aaa@bbb.com & page = 45 "> this is a $ _ GET test
  44. "Demo. php" method = "post">
  45. Username: "Text" name = "uname"/>
  46. Password: "Password" name = "pass"/>
  47. "Submit" value = "login"/>
  48.  
  49. Print_r ($ _ GET); // cannot receive
  50. Print_r ($ _ POST); // to receive
  51. ?>
  52.  
  53. // $ _ ENV usage
  54. Echo'
    ';   
    • Print_r ($ _ ENV );
      • Echo'
      • ';
      • // Display the current environment
      • // You can also traverse
      • ?>
      •  
      • // Use the $ GLOBALS ultra-global array to call global variables within the function
      • $ A = 100;
      • $ B = 200;
      • $ C = 300;
      • Function demo ()
      • {
      • // Directly call global variables
      • Echo $ GLOBALS ["a"]."
        ";
      • Echo $ GLOABLS ["B"]."
        ";
      • Echo $ GLOABLS ["c"]."
        ";
      • }
      • ?>

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.