Simple summary of common magic constants and super-global variables in PHP

Source: Internet
Author: User
This article brings the content is about PHP commonly used magic constants and super-global variables, a simple summary, there is a certain reference value, there is a need for friends to refer to, I hope you have some help.

First, Common Magic constants

Gets the directory where the current file resides, such as: D:\webecho __dir__;//gets the absolute path of the current file, directory + file name, such as: D:\web\index.phpecho __file__;//the class name of the currently running script Echo __class_ _;//the name of the function that is currently running the script echo __function__;//the method name of the currently running script echo __method__;/* Note: In a non-class method body, __function__ is equivalent to __method__;     class method Body __ METHOD__ will contain the class name, such as: classname::methodname*/

Second, the common super-global variables

$_cookie An array of variables passed to the script by HTTP, recorded on the client Print_r ($_cookie); $_cookie[' var_name '] = ' COOKIE ';    Assignment echo $_cookie[' Var_name '];        The value//$_session is stored on the server side of the variable array, need to rely on $_cookiesession_start ();//open SESSION, need to write at the beginning of the file Print_r ($_session); $_session[' Var_ Name '] = ' session ';    Assignment echo $_session[' Var_name '];        Value//$_get get URL carry parameters echo $_get[' param '];//$_post get http using POST method to pass the parameters echo $_post[' param '];

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.