Today we will learn about PHP common system functions server and files

Source: Internet
Author: User

Self-made development projects are not many, $_server and $_files, these two commonly used methods are usually used to manipulate the URL and file upload, I use today's time to familiarize myself with this two commonly used functions, and do some summary, if you need friends, can also see

  1. <?php
  2. Some information in the browser section
  3. echo $_server[' php_self ']. " <br/> "; The function output is the name of your current open file, such as:/default.php
  4. echo $_server[' Gateway_interface ']. " <br/> "; Output your CGI (Gateway Interface) information, such as: cgi/1.1
  5. echo $_server[' http_accept ']. " <br/> ";
  6. echo $_server[' Http_accept_language ']. " <br/> "; Language used by the browser
  7. echo $_server[' http_connection ']. " <br/> "; Pre-requested Connection: The contents of the header.
  8. Some of the functions common to users
  9. echo $_server[' REMOTE_ADDR ']. " <br/> "; #正在浏览当前页面用户的 IP address. such as: 127.0.0.1
  10. echo $_server[' Remote_host ']. " <br/> "; #正在浏览当前页面用户的主机名.
  11. echo $_server[' Remote_port ']. " <br/> "; #用户连接到服务器时所使用的端口. such as: 56634, PHP is unable to obtain the user's MAC address
  1. Some functions on the server side
  2. echo $_server[' Server_admin ']. " <br/> ";//Administrator Information
  3. echo $_server[' Server_port ']. " <br/> "; #服务器所使用的端口, such as: 80
  4. echo $_server[' Script_filename ']. " <br/> "; #当前执行脚本的绝对路径名. such as: f:/www1/default.php
  5. echo $_server[' Document_root ']. " <br/> "; The function is to enter the location of your site, such as: F:/WWW1
  6. echo $_server[' Request_method ']. " <br/> "; How users request access to the page
  7. Some functions about URLs
  8. echo $_server[' query_string ']. " <br/> "; Query string, but it feels like a parameter passed by a GET method
  9. echo $_server[' Http_host ']. " <br> "; #localhost
  10. echo $_server[' php_self ']. " <br> "; Get web address #/blog/testurl.php
  11. echo $_server["Query_string"]. " <br> "; Get URL parameter #id =5
  12. echo $_server[' Http_referer ']. " <br> ";//Get User Agent
  13. Get the full URL
  14. Echo ' http://' $_server[' http_host '].$_server[' Request_uri '];
  15. Echo ' http://'. $_server[' http_host '].$_server[' php_self ']. $_server[' query_string '; #http://localhost/blog/testurl.php?id=5
    1. Echo ' http://'. $_server[' server_name ', '. '. $_server["Server_port"].$_server["Request_uri"]; Full url#http://localhost:80/blog/testurl.php?id=5 with port number
    2. $url = ' http://' $_server[' server_name '].$_server["Request_uri"];
    3. echo dirname ($url);//Fetch path only #http://localhost/blog
  1. ?>
  2. <!------------------get the user's MAC address------------------------>
  3. <?php
  4. @exec ("Arp-a", $array); Executes the ARP-A command, and the result is placed in the array $array
  5. echo "<pre>";
  6. Print_r ($array); Prints the obtained array
  7. foreach ($array as $value)
  8. {
  9. if (//match result put to array $mac_array
  10. Strpos ($value, $_server["REMOTE_ADDR"]) &&
  11. Preg_match ("/(:?? [ 0-9a-f]{2}[:-]) {5}[0-9a-f]{2}/i ", $value, $mac _array)
  12. )
  13. {
  14. $mac = $mac _array[0];
  15. Break
  16. }
  17. }
  18. Echo $mac; Output Client Mac
  19. ?>

About the MAC address, I in the test can get to the LAN station other accounts of the Mac, but my own Mac is unable to obtain, do not know what is the situation, is it my environment problem? I'll take care of it later!

Today we will learn about PHP common system functions server and files

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.