In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces "the introduction of functions, declarations, return values and other features in php7". In daily operation, I believe many people have doubts about the introduction of functions, declarations, return values and other features in php7. I have consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer your doubts about the introduction of functions, declarations, return values and other features in php7. Next, please follow the editor to study!
Use. Operator defines variable length parameter functions (PHP 5 > = 5.6.0, PHP 7)
Now you can use... instead of relying on func_get_args (). Operator to implement a variable-length parameter function.
The above routine outputs:
$req: 1; $opt: 0; number of params: 0
$req: 1; $opt: 2; number of params: 0
$req: 1; $opt: 2; number of params: 1
$req: 1; $opt: 2; number of params: 2
$req: 1; $opt: 2; number of params: 3
Use. Operator for parameter expansion (PHP 5 > = 5.6.0, PHP 7)
When calling a function, use. Operator to expand arrays and traverable objects into function arguments. In other programming languages, such as Ruby, this is called the join operator.
The above routine outputs:
six
Use function and use const (PHP 5 > = 5.6.0, PHP 7)
The use operator has been extended to support importing external functions and constants into the class. The corresponding structures are use function and use const.
The above routine outputs:
forty-two
Name\ Space\ f
DebugInfo () (PHP 5 > = 5.6.0, PHP 7)
Add debugInfo (), which can be used to control the attributes and values to be output when you use var_dump () to output objects.
The above routine outputs:
Object (C) # 1 (1) {["propSquared"] = > int (1764)}
Scalar type declaration (PHP 7)
Scalar type declarations have two modes: mandatory (default) and strict. You can now use the following types of parameters (whether in mandatory mode or strict mode): string (string), integer (int), floating point number (float), and Boolean value (bool). They extend other types introduced in PHP5: class names, interfaces, arrays, and callback types.
Spaceship operator (combination comparator) (PHP 7)
The spaceship operator is used to compare two expressions. It returns-1, 0, or 1 respectively when $an is less than, equal to, or greater than $b. The principle of comparison is based on the general comparison rules of PHP.
Define a constant array through define () (PHP 7)
Constants of type Array can now be defined by define (). It can only be defined through const in PHP5.6.
At this point, the study of "introduction to functions, declarations, return values and other features in php7" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.