`
haohappy2
  • 浏览: 325922 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

New Features Of PHP5.5

 
阅读更多

Generators added

Support for generators has been added via the yield keyword. Generators provide an easy way to implement simple iterators without the overhead or complexity of implementing a class that implements the Iterator interface.

A simple example that reimplements the range() function as a generator (at least for positive step values):

<?php
function xrange($start$limit$step 1) {
    for (
$i $start$i <= $limit$i += $step) {
        
yield $i;
    }
}

echo 
'Single digit odd numbers: ';

/*
 * Note that an array is never created or returned,
 * which saves memory.
 */
foreach (xrange(192) as $number) {
    echo 
"$number ";
}

echo 
"\n";
?>

以上例程会输出:

Single digit odd numbers: 1 3 5 7 9 

finally keyword added

try-catch blocks now support a finally block for code that should be run regardless of whether an exception has been thrown or not.

New password hashing API

A new password hashing API that makes it easier to securely hash and manage passwords using the same underlying library as crypt() in PHP has been added. See the documentation for password_hash() for more detail.

foreach now supports list()

The foreach control structure now supports unpacking nested arrays into separate variables via the list() construct. For example:

<?php
$array 
= [
    [
12],
    [
34],
];

foreach (
$array as list($a$b)) {
    echo 
"A: $a; B: $b\n";
}
?>

以上例程会输出:

A: 1; B: 2
A: 3; B: 4

Further documentation is available on the foreach manual page.

empty() supports arbitrary expressions

Passing an arbitrary expression instead of a variable to empty() is now supported. For example:

<?php
function always_false() {
    return 
false;
}

if (empty(
always_false())) {
    echo 
"This will be printed.\n";
}

if (empty(
true)) {
    echo 
"This will not be printed.\n";
}
?>

以上例程会输出:

This will be printed.

array and string literal dereferencing

Array and string literals can now be dereferenced directly to access individual elements and characters:

<?php
echo 'Array dereferencing: ';
echo [
123][0];
echo 
"\n";

echo 
'String dereferencing: ';
echo 
'PHP'[0];
echo 
"\n";
?>

以上例程会输出:

Array dereferencing: 1
String dereferencing: P

Class name resolution via ::class

It is possible to use ClassName::class to get a fully qualified name of class ClassName. For example:

<?php
namespace Name\Space;
class 
ClassName {}

echo 
ClassName::class;

echo 
"\n";
?>

以上例程会输出:

Name\Space\ClassName

OPcache extension added

The Zend Optimiser+ opcode cache has been added to PHP as the new OPcache extension. OPcache improves PHP performance by storing precompiled script bytecode in shared memory, thereby removing the need for PHP to load and parse scripts on each request. See the installation instructions for more detail on enabling and using OPcache.

foreach now supports non-scalar keys

foreach now supports keys of any type. While non-scalar keys cannot occur in native PHP arrays, it is possible for Iterator::key() to return a value of any type, and this will now be handled correctly.

Apache 2.4 handler supported on Windows

The Apache 2.4 handler SAPI is now supported on Windows.

Improvements to GD

Various improvements have been made to the GD extension, these include:

分享到:
评论

相关推荐

    Modern PHP New Features and Good Practices

    practical techniques that you can immediately implement in your PHP projectGrow your PHP skillset with the newest language features and modern best practicesGet up to speed on new language features of...

    C# 4 New Features

    The CTP contains a number of walkthroughs, some of which highlight the new language features of C# 4.0. Those are excellent for getting a hands-on guided tour through the details of some common ...

    Get Programming with JavaScript Next New features of ECMAScript 2015, 2016, epub

    Get Programming with JavaScript Next New features of ECMAScript 2015, 2016, and beyond 英文epub 本资源转载自网络,如有侵权,请联系上传者或csdn删除查看此书详细信息请在美国亚马逊官网搜索此书

    Java 11 and 12 – New Features

    Enhance your development skills with Java's state-of-the-art features and projects to make your applications leaner and faster... Make the best use of new Java features and libraries in your applications

    Get Programming with JavaScript Next New features of ECMAScript

    Get Programming with JavaScript Next introduces the modern age of JavaScript programming... In just 34 quick-fire sessions, you'll quickly be coding with the latest features and functions of ES6 and ES7!

    Oracle Database 10g:New Features for Administrators Vol 1

    understanding of many of the new features. • Hands-on practices emphasize functionality rather than test knowledge. Overview This course is designed to introduce you to the new features of Oracle ...

    Oracle Database 12c Release 2 New Features epub

    Oracle Database 12c Release 2 New Features 英文epub 本资源转载自网络,如有侵权,请联系上传者或csdn删除 查看此书详细信息请在美国亚马逊官网搜索此书

    MySQL V5.5帮助文档

    1.5. What Is New in MySQL 5.5 1.5.1. Scalability Improvements 1.5.2. InnoDB I/O Subsystem Changes 1.5.3. Enhanced Solaris Support 1.5.4. Diagnostic and Monitoring Capabilities 1.6. MySQL Information ...

    Direction-Change Features of Imaginary Strokes

    We found suitable direction-change features of the imaginary strokes in the pen-up state for on-line handwritten cursive character recognition. Our method simultaneously uses both directional features...

    Modular Programming with PHP 7(PACKT,2016)

    We start with a brief introduction to the new features of PHP 7, some of which open a door to new concepts used in modular development. With design patterns being at the heart of all modular PHP code,...

    Microsoft SQL Server 2005 New Features

    Microsoft SQL Server 2005新特性。

    High Performance MySQL_3rd_edition

    Learn the effects of new features in MySQL 5.5, including stored procedures, partitioned databases, triggers, and views Implement improvements in replication, high availability, and clustering ...

    Swift 3 New Features epub

    Swift 3 New Features 英文epub 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除

    Swift 3 New Features mobi

    Swift 3 New Features 英文mobi 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除

    jdk 1.5 new features jdk新特性

    很重要jdk 1.5 newfeatures jdk新特性 面试必备 我们必须记住。开发必备。学习jdk必备

    Office 365 Azure Active Directory with new features

    Office 365 Azure Active Directory with new features

    Swift.3.New.Features.1786469634

    Implement the new features central to Swift Testing and understand the new debug features Create server-side applications using Swift 3 Table of Contents Chapter 1: What Were They Thinking? Chapter 2:...

    MySQL5.5安装包和安装教程

    2. **选择组件**:在“Select Products and Features”(选择产品和特性)页面,确保勾选“MySQL Server”并选择适当的版本(这里是5.5)。还可以根据需要选择“MySQL Client”(客户端)、“Developer Components”...

Global site tag (gtag.js) - Google Analytics