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

What are the new features of PHP7

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article will explain in detail what the new features of PHP7 are, and the editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.

A very important feature of the PHP language is "weak typing", which makes PHP programs very easy to write, and beginners can get started quickly when they come into contact with PHP, but it also comes with some controversy. Supporting the definition of variable types can be said to be an innovative change, and PHP began to support type definitions in optional ways. In addition, a switch instruction declare (strict_type=1) is introduced; once this instruction is turned on, it will force the program in the current file to follow strict function argument types and return types.

1. Added group support to the use statement

Use FooLibrary\ Bar\ Baz\ {ClassA, ClassB, ClassC, ClassD as Fizbo}

two。 Increase? Operator

Isset ($_ GET ['mykey'])? $_ GET [' mykey']: "" bulky $_ GET ['mykey']? "" An E_NOTICE$_GET [' mykey']? is reported when mykey does not exist. 'defaultvalue' Security will not report E_NOTICE$username = $_ GET ['user']? 'nobody'

3. 64-bit PHP7 strings can be longer than 2 ^ 31 bytes.

4. Add Closure::call support

Closure::call dynamically binds a closure function to a new object instance and calls to execute the function

/ / outputs int (), int ()

5. The use of\ u {xxxxx} to declare unicode characters is supported in double quote strings and heredocs.

6.define 's support for arrays

Define ('ANIMALS', array (' dog', 'cat',' bird')); echo ANIMALS []; / / outputs "cat"

7. Add comparison operator

$a $b

0 if an equals b

1 if an is greater than b

-1 if an is less than b

8.php global reserved words can be declared to use the

Class View {public function include (View $view) {/ /...}}

The include keyword can be used as an ordinary string keyword

9. Scalar type (int,float,string,bool) support

Add declare (strict_types=1) directive to declare whether strict type checking

When declare (strict_types=1) is declared in the header of the file

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

Development

Wechat

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

12
Report