PHP 7.4 in 7 code blocks

栏目: IT技术 · 发布时间: 5年前

内容简介:PHP 7.4, the last edition in the 7.* series, brings lots of new and handy changes. This post lists the highlights, though there's much more to this release. You can read all about the full release in this post aboutArrow functions, a.k.a. short closures.Ty

PHP 7.4, the last edition in the 7.* series, brings lots of new and handy changes. This post lists the highlights, though there's much more to this release. You can read all about the full release in this post about what's new in PHP 7.4 .

array_map(
    fn(User $user) => $user->id,
    $users
);

Arrow functions, a.k.a. short closures.

class A
{
    public string $name;
    
    public ?Foo $foo;
}

Type properties. There's quite a lot to tellabout them.

$data['date'] ??= new DateTime();

The null coalescing assignment operator.

class ParentType {}
class ChildType extends ParentType {}

class A
{
    public function covariantReturnTypes(): ParentType
    { /* … */ }
}

class B extends A
{
    public function covariantReturnTypes(): ChildType
    { /* … */ }
}

Improved type variance. If you're not sure what that's about, you should take a look at this post about Liskov and type safety .

$result = [...$arrayA, ...$arrayB];

The array spread operator.

$formattedNumber = 107_925_284.88;

The numeric literal separator.

[preloading]
opcache.preload=/path/to/project/preload.php

Preloading improves PHP performance across requests.

There's even more. If you want a full list, you can find iton this blog. What 7.4 feature do you like the most? Let me know on Twitter or viaemail.


以上所述就是小编给大家介绍的《PHP 7.4 in 7 code blocks》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

界面设计模式

界面设计模式

Jenifer Tidwell / 东南大学,O‘Reilly / 2011-5 / 99.00元

尽管目前已经存在了各种各样的用户界面设计工具,设计良好的应用界面仍然不是一件容易的事情。这本畅销书是极少数可以信赖的资料,它能帮助你走出设计选项的迷宫。通过把捕捉到的最佳实践和重用思想体现为设计模式,《界面设计模式》提供了针对常见设计问题的解决方案,这些方案可以被裁减以适用于你的具体情况。本修订版包括了手机应用和社交媒体的模式,以及web应用和桌面软件。每个模式包含了用全彩方式展现的运用技巧,以及......一起来看看 《界面设计模式》 这本书的介绍吧!

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具