Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The concept of predefined / Magic constant in PHP

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "the concept of predefined / magic constant in PHP". The explanation in this article is simple and clear and easy to learn and understand. Please follow the editor's train of thought to study and learn "the concept of predefined / magic constant in PHP".

Use define () to define constants, and after PHP 5.3.0, you can also use the const keyword to define constants outside the class definition. Constants can only be scalar data (boolean, integer, float, string), and resource type (resource) constants can also be defined, but should be avoided as much as possible, as this can lead to unpredictable results

Predefined / magic constant

The current line number in the _ LINE__, file.

The full path and file name of the _ _ FILE__, file. If used in the included file, the included file name is returned.

The directory where the _ _ DIR__, file is located. If used in an included file, the directory where the included file is located is returned.

The name of the _ _ FUNCTION__, function, which returns the name when the function was defined.

The name of the _ _ CLASS__, class, which returns the name when the class was defined.

Name of _ _ TRAIT__,Trait (new to PHP 5.4.0). Since PHP 5. 4 this constant returns the name (case sensitive) when trait was defined. The Trait name includes the area in which it is declared (for example, Foo\ Bar).

The name of the method of the _ _ METHOD__, class, which returns the name when the method was defined (case-sensitive).

The name of the current namespace of _ _ NAMESPACE__, (case sensitive).

Thank you for your reading, the above is the content of "the concept of predefined / magic constant in PHP". After the study of this article, I believe you have a deeper understanding of the concept of predefined / magic constant in PHP, 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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report