In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "what are the PHP functions and magic constants". The explanation in the article is simple and clear and easy to learn and understand. Please follow the editor's train of thought to study and learn "what are the PHP functions and magic constants"?
PHP function
The real power of PHP comes from its functions.
In PHP, more than 1000 built-in functions are provided.
.
PHP function
How we are going to create our own functions.
If you want to execute the script when the page loads, you can put it in the function.
The function is executed by calling the function.
You can call the function anywhere on the page.
.
Create a PHP function
The function is executed by calling the function.
Syntax:
PHP function criteria:
The name of the function should indicate its function
The function name begins with a letter or underscore (cannot start with a number)
.
PHP function-add parameters
To add more functionality to the function, we can add parameters. Parameters are similar to variables.
The parameter is specified in parentheses after the function name.
.
PHP function-return value
To have a function return a value, use the return statement.
:
PHP magic constant
PHP provides a large number of predefined constants to any script it runs.
Http://www.iis7.com/a/lm/gjcpmcx/
However, many constants are defined by different extension libraries and appear only when these extension libraries are loaded, either dynamically loaded, or included at compile time.
There are eight magic constants whose values change according to their position in the code.
For example, the value of _ _ LINE__ depends on the line it is on in the script. These special constants are not case-sensitive
.
_ _ LINE__
The current line number in the file.
.
_ _ FILE__
The full path and file name of the file. If used in the included file, the included file name is returned.
Since PHP 4.0.2, _ _ FILE__ has always included an absolute path (or parsed absolute path in the case of symbolic links), while previous versions sometimes included a relative path.
.
_ _ DIR__
The directory where the file is located. If used in an included file, the directory where the included file is located is returned.
It is equivalent to dirname (_ _ FILE__). Unless it is the root directory, the directory name does not include the trailing slash. (new in PHP 5.3.0)
.
_ _ FUNCTION__
Function name (new to PHP 4.3.0). Since PHP 5, this constant returns the name of the function when it was defined (case sensitive). In PHP 4, this value is always lowercase.
.
_ _ CLASS__
The name of the class (new to PHP 4.3.0). Since PHP 5, this constant returns the name of the class when it was defined (case sensitive).
In PHP 4, this value is always lowercase. The class name includes the area in which it is declared (for example, Foo\ Bar). Note that _ _ CLASS__ has also had an effect on trait since PHP 5. 4. When used in the trait method, _ _ CLASS__ is the name of the class that calls the trait method.
.
_ _ TRAIT__
The name of Trait (added to PHP 5.4.0). Since PHP 5.4.0, PHP has implemented a method of code reuse called traits.
The Trait name includes the area in which it is declared (for example, Foo\ Bar).
Members inherited from the base class are overridden by the MyHelloWorld method in the inserted SayWorld Trait. Its behavior is consistent with the methods defined in the MyHelloWorld class. The priority is that the method in the current class overrides the trait method, and the trait method overrides the method in the base class.
.
_ _ METHOD__
The method name of the class (new to PHP 5.0.0). Returns the name of the method when it was defined (case sensitive).
.
_ _ NAMESPACE__
The name of the current namespace (case sensitive). This constant is defined at compile time (new to PHP 5.3.0).
Thank you for your reading, the above is the content of "what are PHP functions and magic constants". After the study of this article, I believe you have a deeper understanding of what PHP functions and magic constants have, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.