In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail how to set constants for php. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
Php set constant method: 1, use define () function, syntax "define ('constant name', 'constant value')"; 2, use const keyword, syntax "const constant name = constant value;"
Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
The so-called constant is a quantity that cannot be changed. Once a constant is defined in PHP, it cannot be modified or undefined.
PHP constants are usually used to store data that is neither changed nor desired, which can only be data of four scalar data types: integer, floating-point, string, and Boolean, but the constant supports array since PHP7.
The method of setting a constant
1. Use the define () function
Legal constant names can only start with letters and underscores, followed by letters, numbers, or underscores of any length. You can define a constant through the define () function in PHP. The syntax of the define () function is as follows:
Define (string $name, mixed $value [, bool $case_insensitive = false])
The arguments to the define () function are described in the following table:
Parameter description $name required parameter, constant name (need to be wrapped in double quotes or single quotation marks) $value required parameter, constant value $case_insensitive optional parameter, specify whether it is case-sensitive. Default is case-sensitive. Setting it to true means case-insensitive.
2. Use the const keyword
In addition to using the define () function, you can also use the const keyword to define constants. The syntax for the const keyword is as follows:
Const constant name = constant value
Here is an example to demonstrate the use of constants:
This is the end of the article on "how to set constants in php". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
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.