First, set the PHP version of the PHP project to PHP 7.0.
One of the new features of PHP 7 is return type declaration, that is, PHP functions and methods can declare return values of specified types:
Another wonderful improvement in PHP 7 is the scalar type declaration of parameters. Netbeans' code autocomplete feature provides support for these new types.
NetBeans also supports new operators in PHP 7:
Group use statement:
Constants can also be grouped using:
Another major feature of PHP 7 - anonymous classes:
8.2 is still a long time away from the release date. If you can’t wait and want to try it out, download address: http://bits.netbeans.org/download/trunk/nightly/latest/
Note:
Generator
(PHP 5 >= 5.5.0, PHP 7)
Generators provide an easier way to implement simple object iteration. Compared with defining a class to implement the Iterator interface, the performance overhead and complexity are greatly reduced.
Generators allow you to write code in a foreach block to iterate over a set of data without creating an array in memory, which would hit your memory limit or take up considerable processing time. Instead, you can write a generator function, just like a normal custom function, and instead of a normal function returning only once, the generator can yield as many times as needed to generate the values that need to be iterated over.
A simple example is to use a generator to reimplement the range() function. The standard range() function needs to generate an array in memory containing every value within its range, and then return the array, resulting in multiple large arrays. For example, calling range(0, 1000000) will cause the memory usage to exceed 100 MB.
As an alternative, we can implement an xrange() generator that only requires enough memory to create the Iterator object and track the current state of the generator internally, thus requiring less than 1K bytes of memory.
Source of this article: http://www.cnblogs.com/x3d/
The above is the entire content of this article. I hope it will be helpful to everyone’s study. For more exciting content, please pay attention to Bangke Home.