新特性

PHP 核心中的新特性

属性添加限定类型

类的属性中现在支持添加指定的类型。

publicint $id;

publicstring $name;

}?>

上面的例子中,会强制要求 $user->id 只能为 int

类型,同时 $user->name 只能为 string 类型。

箭头函数

箭头函数 提供了一种更简洁的定义函数的方法。

$factor=10;$nums=array_map(fn($n) =>$n*$factor, [1,2,3,4]);// $nums = array(10, 20, 30, 40);?>

有限返回类型协变与参数类型逆变

以下代码将不会正常工作:

classBextendsA{}

classProducer{

public functionmethod():A{}

}

classChildProducerextendsProducer{

public functionmethod():B{}

}?>

只有在使用自动加载的情况下,才会有完整的差异支持。在一个文件内,只有非循环类型引用是可能的,因为在引用之前,所有的类都需要可用。

空合并运算符赋值

$array['key'] ??=computeDefault();// 等同于以下旧写法if (!isset($array['key'])) {$array['key'] =computeDefault();

}?>

数组展开操作

$parts= ['apple','pear'];$fruits= ['banana','orange', ...$parts,'watermelon'];// ['banana', 'orange', 'apple', 'pear', 'watermelon'];?>

数值文字分隔符

数字文字可以在数字之间包含下划线。

6.674_083e-11;// float299_792_458;// decimal0xCAFE_F00D;// hexadecimal0b0101_1111;// binary?>

Weak references

Weak references allow the programmer to retain a reference to an object

that does not prevent the object from being destroyed.

允许从 __toString() 抛出异常

现在允许从 __toString()

抛出异常。之前的版本,将会导致一个致命错误。新版本中,之前发生致命错误的代码,已经被转换为

Error 异常。

CURL

CURLFile now supports stream wrappers in addition

to plain file names, if the extension has been built against libcurl >= 7.56.0.

Filter

The FILTER_VALIDATE_FLOAT filter now supports the

min_range and max_range

options, with the same semantics as FILTER_VALIDATE_INT.

FFI

FFI is a new extension, which provides a simple way to call

native functions, access native variables, and create/access

data structures defined in C libraries.

GD

Added the IMG_FILTER_SCATTER image filter

to apply a scatter filter to images.

Hash

Added crc32c hash using Castagnoli's polynomial.

This CRC32 variant is used by storage systems, such as

iSCSI, SCTP, Btrfs and ext4.

Multibyte String

Added the

OPcache

新增 缓存预加载 特性。

Regular Expressions (Perl-Compatible)

The flags argument, with support for the

PREG_OFFSET_CAPTURE and PREG_UNMATCHED_AS_NULL flags.

This influences the format of the matches array passed to to the callback function.

PDO

The username and password can now be specified as part of the PDO DSN for

the mysql, mssql, sybase, dblib, firebird and oci drivers. Previously this

was only supported by the pgsql driver. If a username/password is specified

both in the constructor and the DSN, the constructor takes precedence.

It is now possible to escape question marks in SQL queries to avoid them

being interpreted as parameter placeholders. Writing ??

allows sending a single question mark to the database and e.g. use the

PostgreSQL JSON key exists (?) operator.

PDO_SQLite

PDOStatement::getAttribute(PDO::SQLITE_ATTR_READONLY_STATEMENT)

allows checking whether the statement is read-only, i.e. if it doesn't modify

the database.

PDO::setAttribute(PDO::SQLITE_ATTR_EXTENDED_RESULT_CODES, true)

enables the use of SQLite3 extended result codes in

SQLite3

Added SQLite3::lastExtendedErrorCode()

to fetch the last extended result code.

Added SQLite3::enableExtendedResultCodes($enable = true),

which will make

Standard

strip_tags() with array of tag names

strip_tags($str, '

')

you can now write strip_tags($str, ['a', 'p']).

Custom object serialization

A new mechanism for custom object serialization has been added, which

uses two new magic methods: __serialize

and __unserialize.

The new serialization mechanism supersedes the

Serializable interface,

which will be deprecated in the future.

Array merge functions without arguments

array_merge(...$arrays).

proc_open(['php','-r','echo "Hello World\n";'],$descriptors,$pipes);?>

redirect and null descriptors.

<?php // Like 2>&1 on the shellproc_open($cmd, [1=> ['pipe','w'],2=> ['redirect',1]],$pipes);// Like 2>/dev/null or 2>nul on the shellproc_open($cmd, [1=> ['pipe','w'],2=> ['null']],$pipes);?>

argon2i(d) without libargon

new php,PHP: 新特性 - Manual相关推荐

  1. php 5.6 新特性,PHP 5.6正式发布:新特性、及功能改进介绍

    经过了长时间的开发测试,新版本PHP程序(PHP5.6正式版)终于发布了.新版本中加入了一些实用的新特性,也摒弃了一些冗余的功能.同时,也对部分原有功能进行了改进.下面就一起看看PHP 5.6正式版到 ...

  2. Oracle 11g 新特性简介

    Oracle 11g于2007年7月11日美国东部时间11时(北京时间11日22时)正式发布,11g是甲骨文公司30年来发布的最重要的数据库版本,根据用户的需求实现了信息生命周期管理(Informat ...

  3. php static与self,PHP5.3新特性static与self区别

    很多人都说,PHP 简单,入门门槛较低,但是要学精通确很难.随着 PHP 不断的发展,新特性不断的增加,同时又得兼容老版本 PHP4 的一写语法特征,初学者在学习 PHP 时,显然就不再那么容易了.特 ...

  4. Oracle 19.8新特性asmcmd credverify and asmcmd credfix

    平台:Redhat Linux 7.6 数据库版本:Oracle 19.10 问题描述:进行OCR磁盘替换DD破坏实验,并删除原有的OCR磁盘组.中间过程中,因spfile文件以及asm密码文件没有进 ...

  5. 专家视角 | 小荷的 Oracle Database 18c 新特性快速一瞥

    作者介绍:何剑敏  大疆创新 互联网事业部 运维部数据库技术团队负责人,曾供职于中国联通,卓望数码,IBM 和 ORACLE ACS 华南团队.多年从事一线的数据库运维工作,有丰富项目经验.维护经验和 ...

  6. MySQL 5.0 新特性教程 触发器:第一讲

    滥觞:网海拾贝 作者:mysql AB;翻译:陈朋奕 Conventions and Styles约定和编程作风 每次我想要演示实践代码时,我会对mysql客户真个屏幕就出现的代码阻止调解排解,将字体 ...

  7. PHP 7 的五大新特性

    1. 运算符(NULL 合并运算符) 把这个放在第一个说是因为我觉得它很有用.用法: $a = $_GET['a'] ?? 1; 它相当于: <php $a = isset($_GET['a'] ...

  8. HALCON: HALCON 20.11.0.0 Progress主要新特性

    HALCON: HALCON 20.11.0.0 Progress主要新特性 改进了基于形状的匹配 在HALCON 20.11中,对基于形状匹配的核心技术进行了改进,尤其是针对低对比度和高噪声的场景. ...

  9. 【12c】12c RMAN新特性之通过网络远程恢复数据库(RESTORE/Recover from Service)

    [12c]12c RMAN新特性之通过网络远程恢复数据库(RESTORE/Recover from Service) 通过网络远程恢复数据库(Restore/Recover from Service) ...

最新文章

  1. mysql语句生成工具_强烈推荐一款MySQL语句优化辅助工具,值得收藏
  2. 您的关注是我最大的快乐
  3. Markdown中常用的转义字符
  4. MyBatis——insert并返回主键ID解决方案
  5. Django RestFramework BaseSerializer
  6. python输入input数组_python怎么输入数组
  7. Java ObjectStreamField getName()方法与示例
  8. 安卓系统挂载NTFS格式硬盘_Mac 读写 NTFS硬盘管理开源工具NTFSTool
  9. 认识 UML 类关系——依赖、关联、聚合、组合、泛化
  10. 机票预定系统类图_出行干货|在法国,廉价机票攻略
  11. 金融行业文档管理系统的八大创新
  12. 手动打印日志及日志等级相关-1
  13. shell获取本机ip地址
  14. 【matlab】解方程组
  15. 恋爱计时:只要时间在走,我们的爱就在继续
  16. 新手指南:到国外域名注册商注册域名
  17. 微信公众号开发 (1) 微信接入认证成为开发者
  18. STM32F3 GPIO的八种模式及工作原理
  19. java外加IJ-idea的初次学习
  20. 在vant组件下阻止手机自带键盘弹起

热门文章

  1. 印刷 计算机控制系统,陶瓷印刷计算机直接制版控制系统设计与实现
  2. 改变php二维数组的值_php如何修改二维数组中的值?
  3. 实习日志_【人医札记】护理实习日志
  4. android微信h5转原生支付,微信原生支付流程以及踩坑
  5. 02_反汇编_反编译
  6. 移动发布手机病毒警示信息 发现六种新型病毒
  7. C#编程语言(六):枚举类型与结构类型
  8. [转]解决IE下CSS背景图片闪烁的Bug
  9. Oracle推出支援.NET 3.5与Visual Studio 2008的开发工具
  10. shell中各种括号()、(())、[]、[[]]、{}的作用