<?xml version="1.0" encoding="utf-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><title>秋天的小树</title><link>https://wataru.top/</link><description>Good Luck To You!</description><item><title>HTML5之本地存储localstorage</title><link>https://wataru.top/?id=5</link><description>&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;Web Storage是HTML5引入的一个非常重要的功能，可以在客户端本地存储数据，类似HTML4的cookie，但可实现功能要比cookie强大的多，cookie大小被限制在4KB，Web Storage官方建议为每个网站5MB。&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;Web Storage又分为两种：&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;ul style=&quot;margin-left: 30px; padding: 0px; word-break: break-word; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;sessionStorage&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;localStorage&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;从字面意思就可以很清楚的看出来，sessionStorage将数据保存在session中，浏览器关闭也就没了；而localStorage则一直将数据保存在客户端本地；&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;不管是sessionStorage，还是localStorage，可使用的API都相同，常用的有如下几个（以localStorage为例）：&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;ul style=&quot;margin-left: 30px; padding: 0px; word-break: break-word; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;保存数据：localStorage.setItem(key,value);&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;读取数据：localStorage.getItem(key);&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;删除单个数据：localStorage.removeItem(key);&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;删除所有数据：localStorage.clear();&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;得到某个索引的key：localStorage.key(index);&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;</description><pubDate>Thu, 21 Jan 2021 10:29:36 +0800</pubDate></item><item><title>PHP 8 的 JIT</title><link>https://wataru.top/?id=4</link><description>&lt;p&gt;&lt;span style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; background-color: #EEEEEE;&quot;&gt;JIT是一种编译器策略，它将代码表述为一种中间状态，在运行时将其转换为依赖于体系结构的机器码，并即时执行，在PHP8中，Zend VM不需要解释某些操作码，并且这些指令将直接作为CPU级指令执行。&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;span style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; background-color: #EEEEEE;&quot;&gt;PHP 8 的 JIT&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;span style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; background-color: #EEEEEE;&quot;&gt;PHP 8 Just In Time (JIT) 编译器带来的影响是毋庸置疑的。但是到目前为止，我发现关于 JIT 应该做什么却知之甚少。&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;span style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; background-color: #EEEEEE;&quot;&gt;推荐视频教程：《PHP编程从入门到精通》&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;span style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; background-color: #EEEEEE;&quot;&gt;经过多次研究和放弃，我决定亲自检查 PHP 源代码。结合我对 C 语言的一些知识和我目前收集到的所有零散信息，我提出了这篇文章，我希望它能帮助您更好地理解 PHP 的 JIT。&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;span style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; background-color: #EEEEEE;&quot;&gt;简单一点来说 ： 当 JIT 按预期工作时，您的代码不会通过 Zend VM 执行，而是作为一组 CPU 级指令直接执行。&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;span style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; background-color: #EEEEEE;&quot;&gt;这就是全部的想法。&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;span style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; background-color: #EEEEEE;&quot;&gt;但是为了更好地理解它，我们需要考虑 php 如何在内部工作。不是很复杂，但需要一些介绍。&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;span style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; background-color: #EEEEEE;&quot;&gt;PHP 的代码是怎么执行的？&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;span style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; background-color: #EEEEEE;&quot;&gt;总所周知， PHP 是解释型语言，但这句话本身是什么意思呢？&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;span style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; background-color: #EEEEEE;&quot;&gt;每次执行 PHP 代码（命令行脚本或者 WEB 应用）时，都要经过 PHP 解释器。最常用的是 PHP-FPM 和 CLI 解释器。&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;span style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; background-color: #EEEEEE;&quot;&gt;解释器的工作很简单：接收 PHP 代码，对其进行解释，然后返回结果。&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;span style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; background-color: #EEEEEE;&quot;&gt;一般的解释型语言都是这个流程。有些语言可能会减少几个步骤，但总体的思路相同。在 PHP 中，这个流程如下：&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;span style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; background-color: #EEEEEE;&quot;&gt;读取 PHP 代码并将其解释为一组称为 Tokens 的关键字。这个过程让解释器知道各个程序都写了哪些代码。 这一步称为 Lexing 或 Tokenizing 。&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;span style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; background-color: #EEEEEE;&quot;&gt;拿到 Tokens 集合以后，PHP 解释器将尝试解析他们。通过称之为 Parsing 的过程生成抽象语法树（AST）。这里 AST 是一个节点集表示要执行哪些操作。比如，「 echo 1 + 1 」实际含义是 「打印 1 + 1 的结果」 或者更详细的说 「打印一个操作，这个操作是 1 + 1」。&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;span style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; background-color: #EEEEEE;&quot;&gt;有了 AST ，可以更轻松地理解操作和优先级。将抽象语法树转换成可以被 CPU 执行的操作需要一个用于过渡的表达式 (IR)，在 PHP 中我们称之为 Opcodes 。将 AST 转换为 Opcodes 的过程称为 compilation 。&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;span style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; background-color: #EEEEEE;&quot;&gt;有了 Opcodes ，有趣的部分就来了： executing 代码！ PHP 有一个称为 Zend VM 的引擎，该引擎能够接收一系列 Opcodes 并执行它们。执行所有 Opcodes 后， Zend VM 就会将该程序终止。&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;span style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; background-color: #EEEEEE;&quot;&gt;这是包含 Opcache 扩展的流程示意图：&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;span style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; background-color: #EEEEEE;&quot;&gt;JIT 编译有什么效果？&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;span style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; background-color: #EEEEEE;&quot;&gt;听了 Zeev 在 PHP Internals News 发表的 PHP 和 JIT 广播 之后，我弄清了 JIT 实际做了什么事情。&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;span style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; background-color: #EEEEEE;&quot;&gt;如果说 Opcache 扩展可以更快的获取 Opcodes 将其直接转到 Zend VM，则 JIT 让它们完全不使用 Zend VM 即可运行。&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;span style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; background-color: #EEEEEE;&quot;&gt;Zend VM 是用 C 编写的程序，充当 Opcodes 和 CPU 之间的一层。 JIT 在运行时直接生成编译后的代码，因此 PHP 可以&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;span style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; background-color: #EEEEEE;&quot;&gt;跳过 Zend VM 并直接被 CPU 执行。 从理论上说，性能会更好。&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;span style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; background-color: #EEEEEE;&quot;&gt;这听起来很奇怪，因为在编译成机器码之前，需要为每种类型的结构体编写一个具体的实现。但实际上这也是合理的。&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;span style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; background-color: #EEEEEE;&quot;&gt;PHP 的 JIT 使用了名为 DynASM (Dynamic Assembler) 的库，该库将一种特定格式的一组 CPU 指令映射为许多不同 CPU 类型的汇编代码。因此，编译器只需要使用 DynASM 就可以将 Opcodes 转换为特定结构体的机器码。&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;span style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; background-color: #EEEEEE;&quot;&gt;但是，有一个问题困扰了我很久。&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;span style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; background-color: #EEEEEE;&quot;&gt;如果预加载能够在执行之前将 PHP 代码解析为 Opcodes，并且 DynASM 可以将 Opcodes 编译为机器码 (Just In Time 编译) ，为什么我们不立即使用运行前编译 (Ahead of Time 编译) 立即编译 PHP 呢？&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;span style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; background-color: #EEEEEE;&quot;&gt;通过收听 Zeev 的广播，我找到的原因之一就是 PHP 是弱类型语言，这意味着在 Zend VM 尝试执行某个操作码之前， PHP 通常不知道变量的类型。&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;span style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; background-color: #EEEEEE;&quot;&gt;可以查看 Zend_value 联合类型 得知，很多指针指向不同类型的变量。每当 Zend VM 尝试从 Zend_value 获取值时，它都会使用像 ZSTR_VAL 这样的宏，获取联合类型中字符串的指针。&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;span style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; background-color: #EEEEEE;&quot;&gt;例如，这个 Zend VM handler 是处理「小于或等于」(&amp;lt;=) 表达式。看看它编码这么多的 if else 分支，只是为了类型推断。&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;span style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; background-color: #EEEEEE;&quot;&gt;使用机器码执行类型推断逻辑是不可行的，并且可能变得更慢。&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; white-space: normal; background-color: rgb(238, 238, 238);&quot;/&gt;&lt;span style=&quot;font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; background-color: #EEEEEE;&quot;&gt;先求值再编译也不是一个好选择，因为编译为机器码是 CPU 密集型任务。因此，在运行时编译所有内容也不好。&lt;/span&gt;&lt;/p&gt;</description><pubDate>Wed, 20 Jan 2021 10:27:45 +0800</pubDate></item><item><title>PHP7: Features and Performance Comparison</title><link>https://wataru.top/?id=3</link><description>&lt;p style=&quot;box-sizing: inherit; margin-top: 0px; margin-bottom: 1rem; padding: 0px; font-size: 1.125rem; line-height: 1.6; text-rendering: optimizelegibility; visibility: visible; color: rgb(102, 102, 102); font-family: canada-type-gibson, &amp;quot;helvetica neue&amp;quot;, Helvetica, Arial, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;PHP 7 was a massively redesigned PHP release, offering new language constructs, significant performance improvements, and lower resource utilization. This continues to make&amp;nbsp;it a natural choice for fast-paced business-critical applications.&lt;/p&gt;&lt;p style=&quot;box-sizing: inherit; margin-top: 0px; margin-bottom: 1rem; padding: 0px; font-size: 1.125rem; line-height: 1.6; text-rendering: optimizelegibility; visibility: visible; color: rgb(102, 102, 102); font-family: canada-type-gibson, &amp;quot;helvetica neue&amp;quot;, Helvetica, Arial, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;In this article, we look at PHP 7 features, performance comparisons, end of life, major releases, and why the PHP 7 release marked such a big change for PHP.&lt;/p&gt;&lt;h2 style=&quot;box-sizing: inherit; margin: 0px 0px 0.5rem; padding: 0px; font-family: canada-type-gibson, &amp;quot;helvetica neue&amp;quot;, Helvetica, Arial, sans-serif; color: rgb(6, 121, 234); text-rendering: optimizelegibility; line-height: 1.2; font-size: 2.25rem; visibility: visible; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;What Is PHP 7?&lt;/h2&gt;&lt;blockquote style=&quot;box-sizing: inherit; border-left: 0px; margin: 0px 0px 1rem; padding: 1.5625rem 1.25rem 1.25rem; line-height: 2rem; color: rgb(102, 102, 102); background-color: rgb(247, 247, 247); font-size: 1.375rem; text-align: center; visibility: visible; font-family: canada-type-gibson, &amp;quot;helvetica neue&amp;quot;, Helvetica, Arial, sans-serif; white-space: normal;&quot;&gt;&lt;p style=&quot;box-sizing: inherit; margin-top: 0px; margin-bottom: 1rem; padding: 0px; font-size: 1.125rem; line-height: 1.6; text-rendering: optimizelegibility; visibility: visible;&quot;&gt;PHP 7, released to the public in 2015, followed upon the success of PHP 5.6, and delivered new features and significant performance and resource utilization improvements.&lt;/p&gt;&lt;/blockquote&gt;&lt;h3 style=&quot;box-sizing: inherit; margin: 0px 0px 0.5rem; padding: 0px; font-family: canada-type-gibson, &amp;quot;helvetica neue&amp;quot;, Helvetica, Arial, sans-serif; color: rgb(102, 102, 102); text-rendering: optimizelegibility; line-height: 1.2; font-size: 1.5rem; visibility: visible; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;Release Date&lt;/h3&gt;&lt;p style=&quot;box-sizing: inherit; margin-top: 0px; margin-bottom: 1rem; padding: 0px; font-size: 1.125rem; line-height: 1.6; text-rendering: optimizelegibility; visibility: visible; color: rgb(102, 102, 102); font-family: canada-type-gibson, &amp;quot;helvetica neue&amp;quot;, Helvetica, Arial, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;PHP 7.0 was released on December 3, 2015. The most current version of PHP available, PHP 7.4, was released on November 28, 2019. PHP 7.4 is expected to be the last release of PHP in the 7 series, with PHP 8 expected later in 2020.&lt;/p&gt;&lt;h3 style=&quot;box-sizing: inherit; margin: 0px 0px 0.5rem; padding: 0px; font-family: canada-type-gibson, &amp;quot;helvetica neue&amp;quot;, Helvetica, Arial, sans-serif; color: rgb(102, 102, 102); text-rendering: optimizelegibility; line-height: 1.2; font-size: 1.5rem; visibility: visible; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;End of Life&lt;/h3&gt;&lt;p style=&quot;box-sizing: inherit; margin-top: 0px; margin-bottom: 1rem; padding: 0px; font-size: 1.125rem; line-height: 1.6; text-rendering: optimizelegibility; visibility: visible; color: rgb(102, 102, 102); font-family: canada-type-gibson, &amp;quot;helvetica neue&amp;quot;, Helvetica, Arial, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;PHP 7.0 and 7.1 have both reached end of life. PHP 7.2 reaches end of life on November 30, 2020. Assuming PHP 7.4 is the last version of PHP in the 7 series, PHP 7 will reach total end of life on November 28, 2022.&lt;/p&gt;&lt;h3 style=&quot;box-sizing: inherit; margin: 0px 0px 0.5rem; padding: 0px; font-family: canada-type-gibson, &amp;quot;helvetica neue&amp;quot;, Helvetica, Arial, sans-serif; color: rgb(102, 102, 102); text-rendering: optimizelegibility; line-height: 1.2; font-size: 1.5rem; visibility: visible; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;Major Releases&lt;/h3&gt;&lt;p style=&quot;box-sizing: inherit; margin-top: 0px; margin-bottom: 1rem; padding: 0px; font-size: 1.125rem; line-height: 1.6; text-rendering: optimizelegibility; visibility: visible; color: rgb(102, 102, 102); font-family: canada-type-gibson, &amp;quot;helvetica neue&amp;quot;, Helvetica, Arial, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;PHP 7 has had four major releases since the release of PHP 7.0 in 2015:&lt;/p&gt;&lt;ul style=&quot;box-sizing: inherit; margin-bottom: 1rem; margin-left: 1.25rem; padding: 0px; list-style-position: outside; line-height: 1.6; visibility: visible; color: rgb(102, 102, 102); font-family: canada-type-gibson, &amp;quot;helvetica neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; white-space: normal; background-color: rgb(255, 255, 255);&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.zend.com/blog/guide-php-71&quot; style=&quot;box-sizing: inherit; background-color: transparent; text-decoration-line: none; cursor: pointer; line-height: inherit; color: rgb(6, 121, 234);&quot;&gt;PHP 7.1&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;PHP 7.2&amp;nbsp;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;PHP 7.3&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;a href=&quot;https://www.zend.com/blog/whats-new-php-74&quot; style=&quot;box-sizing: inherit; background-color: transparent; text-decoration-line: none; cursor: pointer; line-height: inherit; color: rgb(6, 121, 234);&quot;&gt;PHP 7.4&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h2 style=&quot;box-sizing: inherit; margin: 0px 0px 0.5rem; padding: 0px; font-family: canada-type-gibson, &amp;quot;helvetica neue&amp;quot;, Helvetica, Arial, sans-serif; color: rgb(6, 121, 234); text-rendering: optimizelegibility; line-height: 1.2; font-size: 2.25rem; visibility: visible; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;PHP 7 Features&lt;/h2&gt;&lt;p style=&quot;box-sizing: inherit; margin-top: 0px; margin-bottom: 1rem; padding: 0px; font-size: 1.125rem; line-height: 1.6; text-rendering: optimizelegibility; visibility: visible; color: rgb(102, 102, 102); font-family: canada-type-gibson, &amp;quot;helvetica neue&amp;quot;, Helvetica, Arial, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;PHP 7 introduced dozens of new features, and huge performance boosts for the community. PHP 7 provided the community with a true high-powered language that can compete in the modern space with any other programming language while introducing some features that many considered to be &amp;quot;missing&amp;quot;.&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;box-sizing: inherit; margin-top: 0px; margin-bottom: 1rem; padding: 0px; font-size: 1.125rem; line-height: 1.6; text-rendering: optimizelegibility; visibility: visible; color: rgb(102, 102, 102); font-family: canada-type-gibson, &amp;quot;helvetica neue&amp;quot;, Helvetica, Arial, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;The most exciting new features of PHP 7 it is now 2x faster than PHP 5. PHP 7 adds static type hinting, which makes possible many of the tools now available for static analysis and static error detection. &amp;nbsp;&lt;/p&gt;&lt;h3 style=&quot;box-sizing: inherit; margin: 0px 0px 0.5rem; padding: 0px; font-family: canada-type-gibson, &amp;quot;helvetica neue&amp;quot;, Helvetica, Arial, sans-serif; color: rgb(102, 102, 102); text-rendering: optimizelegibility; line-height: 1.2; font-size: 1.5rem; visibility: visible; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;Anonymous Classes&lt;/h3&gt;&lt;p style=&quot;box-sizing: inherit; margin-top: 0px; margin-bottom: 1rem; padding: 0px; font-size: 1.125rem; line-height: 1.6; text-rendering: optimizelegibility; visibility: visible; color: rgb(102, 102, 102); font-family: canada-type-gibson, &amp;quot;helvetica neue&amp;quot;, Helvetica, Arial, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;Anonymous classes are a huge step forward for testability in PHP. For example, have you ever wanted to test an abstract class, but didn&amp;#39;t want to extend it? Or needed to change the visibility of a property or method to make it testable? Wanted to test a trait? Anonymous classes are what you need for that.&lt;/p&gt;&lt;pre style=&quot;box-sizing: inherit; overflow: auto; font-family: monospace, monospace; font-size: 16px; margin-top: 0px; margin-bottom: 0px; padding: 0px; color: rgb(102, 102, 102); background-color: rgb(255, 255, 255);&quot; class=&quot;prism-highlight prism-language-php&quot;&gt;&amp;lt;?phptrait&amp;nbsp;SomeTrait&amp;nbsp;{&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&amp;nbsp;function&amp;nbsp;addNumbers($a,&amp;nbsp;$b)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&amp;nbsp;$a&amp;nbsp;+&amp;nbsp;$b;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
}$anonymous&amp;nbsp;=&amp;nbsp;new&amp;nbsp;class&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;use&amp;nbsp;SomeTrait;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/pre&gt;&lt;p style=&quot;box-sizing: inherit; margin-top: 0px; margin-bottom: 1rem; padding: 0px; font-size: 1.125rem; line-height: 1.6; text-rendering: optimizelegibility; visibility: visible; color: rgb(102, 102, 102); font-family: canada-type-gibson, &amp;quot;helvetica neue&amp;quot;, Helvetica, Arial, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;In this example, we&amp;#39;ve defined a trait called SomeTrait, and a public method called addNumbers(). In order to test this, we need to actually put the trait inside of a class. But rather than defining a class, we can simply use the trait inside an anonymous class! Then we can call the method we want to test and verify that it works.&lt;/p&gt;&lt;p style=&quot;box-sizing: inherit; margin-top: 0px; margin-bottom: 1rem; padding: 0px; font-size: 1.125rem; line-height: 1.6; text-rendering: optimizelegibility; visibility: visible; color: rgb(102, 102, 102); font-family: canada-type-gibson, &amp;quot;helvetica neue&amp;quot;, Helvetica, Arial, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;Anonymous classes can receive constructor arguments, meaning they can receive other objects or dependencies that they require to do their work. Anonymous classes can be nested if necessary.&lt;/p&gt;&lt;h3 style=&quot;box-sizing: inherit; margin: 0px 0px 0.5rem; padding: 0px; font-family: canada-type-gibson, &amp;quot;helvetica neue&amp;quot;, Helvetica, Arial, sans-serif; color: rgb(102, 102, 102); text-rendering: optimizelegibility; line-height: 1.2; font-size: 1.5rem; visibility: visible; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;Scalar Type Hints&lt;/h3&gt;&lt;p style=&quot;box-sizing: inherit; margin-top: 0px; margin-bottom: 1rem; padding: 0px; font-size: 1.125rem; line-height: 1.6; text-rendering: optimizelegibility; visibility: visible; color: rgb(102, 102, 102); font-family: canada-type-gibson, &amp;quot;helvetica neue&amp;quot;, Helvetica, Arial, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;Most developers are familiar with the concept of type hints when it comes to type hinting on objects and arrays. Type hinting is useful for indicating the object, interface, or presence of an array that we desire. PHP 7 took this to a next level and included the ability to include scalar type hints for strings, integers, Booleans, and floats.&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;box-sizing: inherit; margin-top: 0px; margin-bottom: 1rem; padding: 0px; font-size: 1.125rem; line-height: 1.6; text-rendering: optimizelegibility; visibility: visible; color: rgb(102, 102, 102); font-family: canada-type-gibson, &amp;quot;helvetica neue&amp;quot;, Helvetica, Arial, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;The scope of the changes is vast. and you&amp;#39;ll want to consult the manual to ensure you fully understand the changes. In general, PHP will attempt to coerce the type you selected, unless strict typing is turned on. The available type hints (in addition to object class names) are self, array, callable, bool, float, int, and string.&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;box-sizing: inherit; margin-top: 0px; margin-bottom: 1rem; padding: 0px; font-size: 1.125rem; line-height: 1.6; text-rendering: optimizelegibility; visibility: visible; color: rgb(102, 102, 102); font-family: canada-type-gibson, &amp;quot;helvetica neue&amp;quot;, Helvetica, Arial, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;Static type hinting is incredibly useful for enforcing the type of argument you want passed to a particular function, and for validating your intent when working with code. For example, if you permit strings and integers, but do arithmetic on the arguments, that could generate a bug. Enforcing an integer only helps ensure that you&amp;#39;re receiving the type that will work with your intended design.&lt;/p&gt;&lt;h3 style=&quot;box-sizing: inherit; margin: 0px 0px 0.5rem; padding: 0px; font-family: canada-type-gibson, &amp;quot;helvetica neue&amp;quot;, Helvetica, Arial, sans-serif; color: rgb(102, 102, 102); text-rendering: optimizelegibility; line-height: 1.2; font-size: 1.5rem; visibility: visible; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;Return Type Hints&lt;/h3&gt;&lt;p style=&quot;box-sizing: inherit; margin-top: 0px; margin-bottom: 1rem; padding: 0px; font-size: 1.125rem; line-height: 1.6; text-rendering: optimizelegibility; visibility: visible; color: rgb(102, 102, 102); font-family: canada-type-gibson, &amp;quot;helvetica neue&amp;quot;, Helvetica, Arial, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;Along with scalar type hints, we also got return type hints. Return type hints allow you to specify the return type that you expect for a given function or method of an object.&lt;/p&gt;&lt;pre style=&quot;box-sizing: inherit; overflow: auto; font-family: monospace, monospace; font-size: 16px; margin-top: 0px; margin-bottom: 0px; padding: 0px; color: rgb(102, 102, 102); background-color: rgb(255, 255, 255);&quot;&gt;&amp;lt;?phpclass&amp;nbsp;MyClass{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&amp;nbsp;function&amp;nbsp;myMethod()&amp;nbsp;:&amp;nbsp;string
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&amp;nbsp;&amp;quot;hello&amp;nbsp;world!&amp;quot;;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
}&lt;/pre&gt;&lt;p style=&quot;box-sizing: inherit; margin-top: 0px; margin-bottom: 1rem; padding: 0px; font-size: 1.125rem; line-height: 1.6; text-rendering: optimizelegibility; visibility: visible; color: rgb(102, 102, 102); font-family: canada-type-gibson, &amp;quot;helvetica neue&amp;quot;, Helvetica, Arial, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;Here we&amp;#39;ve defined a class that contains a method that returns a string. We know it returns a string because we have defined the return type. If we inadvertently return anything else, say an integer or a boolean, PHP will complain, and an error will be generated.&lt;/p&gt;&lt;p style=&quot;box-sizing: inherit; margin-top: 0px; margin-bottom: 1rem; padding: 0px; font-size: 1.125rem; line-height: 1.6; text-rendering: optimizelegibility; visibility: visible; color: rgb(102, 102, 102); font-family: canada-type-gibson, &amp;quot;helvetica neue&amp;quot;, Helvetica, Arial, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;In general, it&amp;#39;s a good idea to return type hint all of your methods as much as you can, and stick with a single return type declaration (using exceptions for events that are out of scope for your method to handle).&amp;nbsp;&lt;/p&gt;&lt;h3 style=&quot;box-sizing: inherit; margin: 0px 0px 0.5rem; padding: 0px; font-family: canada-type-gibson, &amp;quot;helvetica neue&amp;quot;, Helvetica, Arial, sans-serif; color: rgb(102, 102, 102); text-rendering: optimizelegibility; line-height: 1.2; font-size: 1.5rem; visibility: visible; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;Engine Exceptions&lt;/h3&gt;&lt;p style=&quot;box-sizing: inherit; margin-top: 0px; margin-bottom: 1rem; padding: 0px; font-size: 1.125rem; line-height: 1.6; text-rendering: optimizelegibility; visibility: visible; color: rgb(102, 102, 102); font-family: canada-type-gibson, &amp;quot;helvetica neue&amp;quot;, Helvetica, Arial, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;In PHP 7, the engine moved to using exceptions under the hood for raising fatal errors. A Throwable class was introduced for exceptions, and all exceptions use the Throwable class to raise their exception. From there, PHP branches exceptions into two categories: errors and the traditional Exception class we&amp;#39;ve all come to know.&lt;/p&gt;&lt;p style=&quot;box-sizing: inherit; margin-top: 0px; margin-bottom: 1rem; padding: 0px; font-size: 1.125rem; line-height: 1.6; text-rendering: optimizelegibility; visibility: visible; color: rgb(102, 102, 102); font-family: canada-type-gibson, &amp;quot;helvetica neue&amp;quot;, Helvetica, Arial, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;Error is further extended to various types of error like ParseError and TypeError. You can type hint for, and catch, these exceptions as appropriate. Just bear in mind you should generally not catch all exceptions, including parse errors. However, you can catch all errors by catching the Throwable exception interface.&lt;/p&gt;&lt;p style=&quot;box-sizing: inherit; margin-top: 0px; margin-bottom: 1rem; padding: 0px; font-size: 1.125rem; line-height: 1.6; text-rendering: optimizelegibility; visibility: visible; color: rgb(102, 102, 102); font-family: canada-type-gibson, &amp;quot;helvetica neue&amp;quot;, Helvetica, Arial, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;Throwable cannot be extended by userland developers.&amp;nbsp;&lt;/p&gt;&lt;h2 style=&quot;box-sizing: inherit; margin: 0px 0px 0.5rem; padding: 0px; font-family: canada-type-gibson, &amp;quot;helvetica neue&amp;quot;, Helvetica, Arial, sans-serif; color: rgb(6, 121, 234); text-rendering: optimizelegibility; line-height: 1.2; font-size: 2.25rem; visibility: visible; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;New Syntax Features in PHP 7&lt;/h2&gt;&lt;p style=&quot;box-sizing: inherit; margin-top: 0px; margin-bottom: 1rem; padding: 0px; font-size: 1.125rem; line-height: 1.6; text-rendering: optimizelegibility; visibility: visible; color: rgb(102, 102, 102); font-family: canada-type-gibson, &amp;quot;helvetica neue&amp;quot;, Helvetica, Arial, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;PHP 7 introduced a large number of new syntax features that are incredibly helpful for developers to know and use on a daily basis. This &amp;quot;syntactical sugar&amp;quot; will make development in PHP 7 considerably easier.&lt;/p&gt;&lt;h3 style=&quot;box-sizing: inherit; margin: 0px 0px 0.5rem; padding: 0px; font-family: canada-type-gibson, &amp;quot;helvetica neue&amp;quot;, Helvetica, Arial, sans-serif; color: rgb(102, 102, 102); text-rendering: optimizelegibility; line-height: 1.2; font-size: 1.5rem; visibility: visible; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;Group Import Declarations&lt;/h3&gt;&lt;p style=&quot;box-sizing: inherit; margin-top: 0px; margin-bottom: 1rem; padding: 0px; font-size: 1.125rem; line-height: 1.6; text-rendering: optimizelegibility; visibility: visible; color: rgb(102, 102, 102); font-family: canada-type-gibson, &amp;quot;helvetica neue&amp;quot;, Helvetica, Arial, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;Namespaces were introduced in PHP 5.3, and have become popular for the development of PHP applications. There are times when you want to introduce multiple classes from the same namespace. Prior to PHP 7 this was a cumbersome process involving tens or dozens of lines of boilerplate at the beginning of a file. In PHP 7, we received group import statements.&lt;/p&gt;&lt;p style=&quot;box-sizing: inherit; margin-top: 0px; margin-bottom: 1rem; padding: 0px; font-size: 1.125rem; line-height: 1.6; text-rendering: optimizelegibility; visibility: visible; color: rgb(102, 102, 102); font-family: canada-type-gibson, &amp;quot;helvetica neue&amp;quot;, Helvetica, Arial, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;A group import statement is just what it sounds like: we group what we&amp;#39;re importing, so the base namespace is the same, and we list out what we&amp;#39;re importing.&lt;/p&gt;&lt;pre style=&quot;box-sizing: inherit; overflow: auto; font-family: monospace, monospace; font-size: 16px; margin-top: 0px; margin-bottom: 0px; padding: 0px; color: rgb(102, 102, 102); background-color: rgb(255, 255, 255);&quot;&gt;&amp;lt;?php//&amp;nbsp;THISuse&amp;nbsp;My\Great\Namespace\ClassA;use&amp;nbsp;My\Great\Namespace\ClassB;use&amp;nbsp;My\Great\Namespace\ClassC;use&amp;nbsp;My\Great\Namespace\ClassD;//&amp;nbsp;BECOMES&amp;nbsp;THISuse&amp;nbsp;My\Great\Namespace\{ClassA,&amp;nbsp;ClassB,&amp;nbsp;ClassC,&amp;nbsp;ClassD};&lt;/pre&gt;&lt;p style=&quot;box-sizing: inherit; margin-top: 0px; margin-bottom: 1rem; padding: 0px; font-size: 1.125rem; line-height: 1.6; text-rendering: optimizelegibility; visibility: visible; color: rgb(102, 102, 102); font-family: canada-type-gibson, &amp;quot;helvetica neue&amp;quot;, Helvetica, Arial, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;Most of the modern PHP IDE&amp;#39;s support the use of group import.&lt;/p&gt;&lt;h3 style=&quot;box-sizing: inherit; margin: 0px 0px 0.5rem; padding: 0px; font-family: canada-type-gibson, &amp;quot;helvetica neue&amp;quot;, Helvetica, Arial, sans-serif; color: rgb(102, 102, 102); text-rendering: optimizelegibility; line-height: 1.2; font-size: 1.5rem; visibility: visible; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;Null Coalescing Operator&lt;/h3&gt;&lt;p style=&quot;box-sizing: inherit; margin-top: 0px; margin-bottom: 1rem; padding: 0px; font-size: 1.125rem; line-height: 1.6; text-rendering: optimizelegibility; visibility: visible; color: rgb(102, 102, 102); font-family: canada-type-gibson, &amp;quot;helvetica neue&amp;quot;, Helvetica, Arial, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;Another bit of sugar added to PHP 7 was the ability to use a null coalescing operator. This operator assigns a variable based on whether or not the first value is null. For example:&lt;/p&gt;&lt;pre style=&quot;box-sizing: inherit; overflow: auto; font-family: monospace, monospace; font-size: 16px; margin-top: 0px; margin-bottom: 0px; padding: 0px; color: rgb(102, 102, 102); background-color: rgb(255, 255, 255);&quot;&gt;&amp;lt;?php$username&amp;nbsp;=&amp;nbsp;$_POST[&amp;#39;user&amp;#39;]&amp;nbsp;??&amp;nbsp;&amp;#39;no&amp;nbsp;name&amp;nbsp;specified&amp;#39;;&lt;/pre&gt;&lt;p style=&quot;box-sizing: inherit; margin-top: 0px; margin-bottom: 1rem; padding: 0px; font-size: 1.125rem; line-height: 1.6; text-rendering: optimizelegibility; visibility: visible; color: rgb(102, 102, 102); font-family: canada-type-gibson, &amp;quot;helvetica neue&amp;quot;, Helvetica, Arial, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;The benefit of this is that it shortens the syntax required to check if a value is null and assign something else.&amp;nbsp;&lt;/p&gt;&lt;h3 style=&quot;box-sizing: inherit; margin: 0px 0px 0.5rem; padding: 0px; font-family: canada-type-gibson, &amp;quot;helvetica neue&amp;quot;, Helvetica, Arial, sans-serif; color: rgb(102, 102, 102); text-rendering: optimizelegibility; line-height: 1.2; font-size: 1.5rem; visibility: visible; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;Spaceship Operator&lt;/h3&gt;&lt;p style=&quot;box-sizing: inherit; margin-top: 0px; margin-bottom: 1rem; padding: 0px; font-size: 1.125rem; line-height: 1.6; text-rendering: optimizelegibility; visibility: visible; color: rgb(102, 102, 102); font-family: canada-type-gibson, &amp;quot;helvetica neue&amp;quot;, Helvetica, Arial, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;The spaceship operator is a fairly simple tool for comparing two expressions. The spaceship operator compares expressions by determining whether the left-most parameter ($a) is less than, equal to, or greater than the right-most parameter ($b), and returns -1 (less than), 0 (equal to), or 1 (greater than). It can be used to compare integers, floats, and even strings.&amp;nbsp;&lt;/p&gt;&lt;h2 style=&quot;box-sizing: inherit; margin: 0px 0px 0.5rem; padding: 0px; font-family: canada-type-gibson, &amp;quot;helvetica neue&amp;quot;, Helvetica, Arial, sans-serif; color: rgb(6, 121, 234); text-rendering: optimizelegibility; line-height: 1.2; font-size: 2.25rem; visibility: visible; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;PHP 7 Performance&lt;/h2&gt;&lt;p style=&quot;box-sizing: inherit; margin-top: 0px; margin-bottom: 1rem; padding: 0px; font-size: 1.125rem; line-height: 1.6; text-rendering: optimizelegibility; visibility: visible; color: rgb(102, 102, 102); font-family: canada-type-gibson, &amp;quot;helvetica neue&amp;quot;, Helvetica, Arial, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;PHP 7 dramatically improves the performance of PHP, in many cases coming close to or even doubling the performance of an application over PHP 5.x. This performance enhancement is possible due to the tremendous work of the PHP core team, specifically in their rewrite of the underlying components of PHP to make them faster. Each incremental release of PHP 7 provides further boosts in performance over PHP 7.0.&lt;/p&gt;&lt;ul style=&quot;box-sizing: inherit; margin-bottom: 1rem; margin-left: 1.25rem; padding: 0px; list-style-position: outside; line-height: 1.6; visibility: visible; color: rgb(102, 102, 102); font-family: canada-type-gibson, &amp;quot;helvetica neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; white-space: normal; background-color: rgb(255, 255, 255);&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;&lt;span style=&quot;box-sizing: inherit; font-weight: 600; line-height: inherit;&quot;&gt;Drupal -&lt;/span&gt;&amp;nbsp;Compared to previous versions, Drupal 8 runs 72 percent faster on PHP 7 when compared to previous versions.&amp;nbsp;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;span style=&quot;box-sizing: inherit; font-weight: 600; line-height: inherit;&quot;&gt;Wordpress -&lt;/span&gt;&amp;nbsp;For WordPress, a PHP 7 runtime only executes 25M CPU instructions compared to just under 100M doing the same job on older PHP versions.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;span style=&quot;box-sizing: inherit; font-weight: 600; line-height: inherit;&quot;&gt;Magento -&lt;/span&gt;&amp;nbsp;For Magento, servers running PHP 7 are able to serve up to three times more requests as those running PHP 5.6.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;box-sizing: inherit; margin-top: 0px; margin-bottom: 1rem; padding: 0px; font-size: 1.125rem; line-height: 1.6; text-rendering: optimizelegibility; visibility: visible; color: rgb(102, 102, 102); font-family: canada-type-gibson, &amp;quot;helvetica neue&amp;quot;, Helvetica, Arial, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;The benchmarks were also confirmed with larger enterprise applications. When the Tumblr team rolled out PHP 7, they experienced a latency drop of 50 percent, and their CPU load decreased at least 50 percent, often more.&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;</description><pubDate>Mon, 18 Jan 2021 10:13:16 +0800</pubDate></item><item><title>欢迎使用Z-BlogPHP！</title><link>https://wataru.top/?id=1</link><description>&lt;p&gt;欢迎使用Z-Blog，这是程序自动生成的文章，您可以删除或是编辑它:)&lt;/p&gt;&lt;p&gt;系统生成了一个留言本和一篇《欢迎使用Z-BlogPHP！》，祝您使用愉快！&lt;/p&gt;</description><pubDate>Sun, 20 Dec 2020 11:31:35 +0800</pubDate></item></channel></rss>