内容简介: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》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
深入浅出Rust
范长春 / 机械工业出版社 / 2018-8-21 / 89.00元
本书详细描述了Rust语言的基本语法,穿插讲解一部分高级使用技巧,并以更容易理解的方式解释其背后的设计思想。全书总共分五个部分。 第一部分介绍Rust基本语法,因为对任何程序设计语言来说,语法都是基础,学习这部分是理解其他部分的前提。 第二部分介绍属于Rust独一无二的内存管理方式。它设计了一组全新的机制,既保证了安全性,又保持了强大的内存布局控制力,而且没有额外性能损失。这部分是本书......一起来看看 《深入浅出Rust》 这本书的介绍吧!