<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title type="text">PHP &amp; Docker</title>
  <id>http://prophet777.postach.io/feed.xml</id>
  <updated>2017-12-28T13:45:13.993000Z</updated>
  <link href="http://prophet777.postach.io/" />
  <link href="http://prophet777.postach.io/feed.xml" rel="self" />
  <generator>Werkzeug</generator>
  <entry xml:base="http://prophet777.postach.io/feed.xml">
    <title type="text">Docker and logs</title>
    <id>https://prophet777.postach.io/post/docker-and-logs</id>
    <updated>2017-12-28T13:36:16.901000Z</updated>
    <published>2017-01-17T11:32:04Z</published>
    <link href="https://prophet777.postach.io/post/docker-and-logs" />
    <author>
      <name>prophet777</name>
    </author>
    <category term="tips" />
    <category term="docker" />
    <category term="logs" />
    <content type="html">&lt;div&gt;&lt;del style=&quot;position:relative;display:block;z-index:10;&quot;&gt;&lt;a  style=&quot;position: absolute;color: #FFF;text-decoration: none;font-size: 12px;height: 25px;border-radius: 0;margin-top: -20px;right: 15px;background: rgba(0, 0, 0, 0);border-left: 10px solid #BB3A34;border-right: 10px solid #BB3A34;border-bottom: 5px solid rgba(0, 0, 0, 0);width: 0;text-indent:-100000px;&quot; href=&quot;http://marxi.co/#/?provider=evernote_int&amp;guid=356f68f2-1624-4e18-b9e7-becf802b0a55&amp;notebook=Postach.io&quot;&gt;Edit&lt;/a&gt;&lt;/del&gt;&lt;div  style=&quot;color: #2c3f51; line-height: 1.6;&quot;&gt;
                        
                    



&lt;h1 style=&quot;font-size: 41.6px; margin: 1.2em 0 .6em 0; font-family: inherit; font-weight: bold; line-height: 1.1; color: inherit; margin-top: 21px; margin-bottom: 10.5px; text-align: start;&quot;&gt;Docker and logs&lt;/h1&gt;

&lt;p style=&quot;margin: 0 0 1.1em; line-height: 1.6;&quot;/&gt;



&lt;p style=&quot;margin: 0 0 1.1em; line-height: 1.6;&quot;&gt;&lt;img src=&quot;https://cdn-images.postach.io/0ae34934-1fa7-4ba9-8006-c5903a09de37/356f68f2-1624-4e18-b9e7-becf802b0a55/086653f2-6f49-4869-98a1-83a66219c47f.png&quot;  longdesc=&quot;./docker-tribe.png&quot; alt=&quot;Alt text&quot; style=&quot;border: 0; vertical-align: middle; max-width: 100%;&quot;/&gt;&lt;/p&gt;



&lt;h2 style=&quot;font-family: inherit; font-weight: bold; line-height: 1.1; color: inherit; margin-top: 21px; margin-bottom: 10.5px; font-size: 34.4px; margin: 1.2em 0 .6em 0; text-align: start;&quot;&gt;How docker logging works ?&lt;/h2&gt;

&lt;p style=&quot;margin: 0 0 1.1em; line-height: 1.6;&quot;&gt;It’s very simple, to log from a container, you have to write in &lt;code style=&quot;font-family: 'Source Code Pro',monospace; font-size: .9em; padding: 2px 4px; color: #c7254e; background-color: #f9f2f4; white-space: normal; border-radius: 4px;&quot;&gt;stdout&lt;/code&gt; !&lt;/p&gt;



&lt;h2 style=&quot;font-family: inherit; font-weight: bold; line-height: 1.1; color: inherit; margin-top: 21px; margin-bottom: 10.5px; font-size: 34.4px; margin: 1.2em 0 .6em 0; text-align: start;&quot;&gt;Where container logs are sent ? How can I see it ?&lt;/h2&gt;

&lt;p style=&quot;margin: 0 0 1.1em; line-height: 1.6;&quot;&gt;It’s a best practice to log on &lt;code style=&quot;font-family: 'Source Code Pro',monospace; font-size: .9em; padding: 2px 4px; color: #c7254e; background-color: #f9f2f4; white-space: normal; border-radius: 4px;&quot;&gt;stdout&lt;/code&gt; from a container, it’s an unified interface and directly available from &lt;code style=&quot;font-family: 'Source Code Pro',monospace; font-size: .9em; padding: 2px 4px; color: #c7254e; background-color: #f9f2f4; white-space: normal; border-radius: 4px;&quot;&gt;docker logs -f [container]&lt;/code&gt; or through &lt;code style=&quot;font-family: 'Source Code Pro',monospace; font-size: .9em; padding: 2px 4px; color: #c7254e; background-color: #f9f2f4; white-space: normal; border-radius: 4px;&quot;&gt;docker-compose logs -f&lt;/code&gt;. Howerver docker save the output produced by containers in &lt;code style=&quot;font-family: 'Source Code Pro',monospace; font-size: .9em; padding: 2px 4px; color: #c7254e; background-color: #f9f2f4; white-space: normal; border-radius: 4px;&quot;&gt;/var/lib/docker/containers/[CONTAINER ID]/[CONTAINER_ID]-json.log&lt;/code&gt; by default. Json file is the default log driver, the most easier.&lt;/p&gt;

&lt;p style=&quot;margin: 0 0 1.1em; line-height: 1.6;&quot;&gt;Docker many built in log driver like as following : &lt;/p&gt;

&lt;ul style=&quot;margin-top: 0; margin-bottom: 1.1em; line-height: 1.6;&quot;&gt;&lt;li style=&quot;line-height: 1.6;&quot;&gt;&lt;strong style=&quot;font-weight: bold; line-height: 1.6;&quot;&gt;none:&lt;/strong&gt; No logs will be available for the container and docker logs will not return any output.  &lt;/li&gt;
&lt;li style=&quot;line-height: 1.6;&quot;&gt;&lt;strong style=&quot;font-weight: bold; line-height: 1.6;&quot;&gt;json-file:&lt;/strong&gt;    The logs are formatted as JSON. The default logging driver for Docker.   &lt;/li&gt;
&lt;li style=&quot;line-height: 1.6;&quot;&gt;&lt;strong style=&quot;font-weight: bold; line-height: 1.6;&quot;&gt;syslog:&lt;/strong&gt;   Writes logging messages to the syslog facility. The syslog daemon must be running on the host machine.   &lt;/li&gt;
&lt;li style=&quot;line-height: 1.6;&quot;&gt;&lt;strong style=&quot;font-weight: bold; line-height: 1.6;&quot;&gt;journald:&lt;/strong&gt; Writes log messages to journald. The journald daemon must be running on the host machine.    &lt;/li&gt;
&lt;li style=&quot;line-height: 1.6;&quot;&gt;&lt;strong style=&quot;font-weight: bold; line-height: 1.6;&quot;&gt;gelf:&lt;/strong&gt; Writes log messages to a Graylog Extended Log Format (GELF) endpoint such as Graylog or Logstash.    &lt;/li&gt;
&lt;li style=&quot;line-height: 1.6;&quot;&gt;&lt;strong style=&quot;font-weight: bold; line-height: 1.6;&quot;&gt;fluentd:&lt;/strong&gt;  Writes log messages to fluentd (forward input). The fluentd daemon must be running on the host machine.  &lt;/li&gt;
&lt;li style=&quot;line-height: 1.6;&quot;&gt;&lt;strong style=&quot;font-weight: bold; line-height: 1.6;&quot;&gt;awslogs:&lt;/strong&gt;  Writes log messages to Amazon CloudWatch Logs.   &lt;/li&gt;
&lt;li style=&quot;line-height: 1.6;&quot;&gt;&lt;strong style=&quot;font-weight: bold; line-height: 1.6;&quot;&gt;splunk:&lt;/strong&gt;   Writes log messages to splunk using the HTTP Event Collector.    &lt;/li&gt;
&lt;li style=&quot;line-height: 1.6;&quot;&gt;&lt;strong style=&quot;font-weight: bold; line-height: 1.6;&quot;&gt;etwlogs:&lt;/strong&gt;  Writes log messages as Event Tracing for Windows (ETW) events. Only available on Windows platforms.  &lt;/li&gt;
&lt;li style=&quot;line-height: 1.6;&quot;&gt;&lt;strong style=&quot;font-weight: bold; line-height: 1.6;&quot;&gt;gcplogs:&lt;/strong&gt;  Writes log messages to Google Cloud Platform (GCP) Logging.  &lt;/li&gt;
&lt;li style=&quot;line-height: 1.6;&quot;&gt;&lt;strong style=&quot;font-weight: bold; line-height: 1.6;&quot;&gt;nats:&lt;/strong&gt; NATS logging driver for Docker. Publishes log entries to a NATS server.&lt;/li&gt;
&lt;/ul&gt;

&lt;p style=&quot;margin: 0 0 1.1em; line-height: 1.6;&quot;&gt;&lt;code style=&quot;font-family: 'Source Code Pro',monospace; font-size: .9em; padding: 2px 4px; color: #c7254e; background-color: #f9f2f4; white-space: normal; border-radius: 4px;&quot;&gt;docker logs&lt;/code&gt; command is only available with &lt;code style=&quot;font-family: 'Source Code Pro',monospace; font-size: .9em; padding: 2px 4px; color: #c7254e; background-color: #f9f2f4; white-space: normal; border-radius: 4px;&quot;&gt;json-file&lt;/code&gt; and &lt;code style=&quot;font-family: 'Source Code Pro',monospace; font-size: .9em; padding: 2px 4px; color: #c7254e; background-color: #f9f2f4; white-space: normal; border-radius: 4px;&quot;&gt;journald&lt;/code&gt;, than mean you need to bring your infrastructure to visualize your logs!&lt;/p&gt;

&lt;p style=&quot;margin: 0 0 1.1em; line-height: 1.6;&quot;&gt;With &lt;code style=&quot;font-family: 'Source Code Pro',monospace; font-size: .9em; padding: 2px 4px; color: #c7254e; background-color: #f9f2f4; white-space: normal; border-radius: 4px;&quot;&gt;json-file&lt;/code&gt; driver you will out of disk space, mostly if you work with worker (or application) which produce a huge amount of logs. You specify some parameters in order to avoid that. &lt;/p&gt;

&lt;ul style=&quot;margin-top: 0; margin-bottom: 1.1em; line-height: 1.6;&quot;&gt;&lt;li style=&quot;line-height: 1.6;&quot;&gt;&lt;strong style=&quot;font-weight: bold; line-height: 1.6;&quot;&gt;max-size&lt;/strong&gt; The maximum size of the log before it is rolled. A positive integer plus a modifier representing the unit of measure (k, m, or g).&lt;/li&gt;
&lt;/ul&gt;



&lt;pre  style=&quot;font-family: 'Source Code Pro',monospace; white-space: pre-wrap; display: block; background-color: rgba(102,128,153,0.05); color: #333; word-wrap: break-word; font-size: .9em; background: #f6f6f6; line-height: 1.6; margin: 0 0 1.1em; padding: 0; border: 0; border-radius: 5px; text-align: start; word-break: break-all;&quot;&gt;&lt;code  style=&quot;font-family: 'Source Code Pro',monospace; font-size: inherit; background-color: transparent; white-space: pre-wrap; border-radius: 0; color: #f8f8f2; display: block; overflow-x: auto; background: #23241f; padding: 1.3em 2em;&quot;&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;--&lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;log&lt;/span&gt;-opt &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;max&lt;/span&gt;-&lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;size&lt;/span&gt;=0m
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;ul style=&quot;margin-top: 0; margin-bottom: 1.1em; line-height: 1.6;&quot;&gt;&lt;li style=&quot;line-height: 1.6;&quot;&gt;&lt;strong style=&quot;font-weight: bold; line-height: 1.6;&quot;&gt;max-file&lt;/strong&gt; The maximum number of log files that can be present. If rolling the logs creates excess files, the oldest file is removed. &lt;strong style=&quot;font-weight: bold; line-height: 1.6;&quot;&gt;Only effective&lt;/strong&gt; when max-size &lt;strong style=&quot;font-weight: bold; line-height: 1.6;&quot;&gt;is also set&lt;/strong&gt;. A positive integer.&lt;/li&gt;
&lt;/ul&gt;

&lt;pre  style=&quot;font-family: 'Source Code Pro',monospace; white-space: pre-wrap; display: block; background-color: rgba(102,128,153,0.05); color: #333; word-wrap: break-word; font-size: .9em; background: #f6f6f6; line-height: 1.6; margin: 0 0 1.1em; padding: 0; border: 0; border-radius: 5px; text-align: start; word-break: break-all;&quot;&gt;&lt;code  style=&quot;font-family: 'Source Code Pro',monospace; font-size: inherit; background-color: transparent; white-space: pre-wrap; border-radius: 0; color: #f8f8f2; display: block; overflow-x: auto; background: #23241f; padding: 1.3em 2em;&quot;&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;--&lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;log&lt;/span&gt;-&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;opt&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;max&lt;/span&gt;-&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;file&lt;/span&gt;=&lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;3&lt;/span&gt;
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;ul style=&quot;margin-top: 0; margin-bottom: 1.1em; line-height: 1.6;&quot;&gt;&lt;li style=&quot;line-height: 1.6;&quot;&gt;&lt;strong style=&quot;font-weight: bold; line-height: 1.6;&quot;&gt;labels&lt;/strong&gt; Applies when starting the Docker daemon. A comma-separated list of logging-related labels this daemon will accept. Used for advanced log tag options.&lt;/li&gt;
&lt;/ul&gt;

&lt;pre  style=&quot;font-family: 'Source Code Pro',monospace; white-space: pre-wrap; display: block; background-color: rgba(102,128,153,0.05); color: #333; word-wrap: break-word; font-size: .9em; background: #f6f6f6; line-height: 1.6; margin: 0 0 1.1em; padding: 0; border: 0; border-radius: 5px; text-align: start; word-break: break-all;&quot;&gt;&lt;code  style=&quot;font-family: 'Source Code Pro',monospace; font-size: inherit; background-color: transparent; white-space: pre-wrap; border-radius: 0; color: #f8f8f2; display: block; overflow-x: auto; background: #23241f; padding: 1.3em 2em;&quot;&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;--&lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;log&lt;/span&gt;-opt &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;labels&lt;/span&gt;=production_status,geo
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;ul style=&quot;margin-top: 0; margin-bottom: 1.1em; line-height: 1.6;&quot;&gt;&lt;li style=&quot;line-height: 1.6;&quot;&gt;&lt;strong style=&quot;font-weight: bold; line-height: 1.6;&quot;&gt;env&lt;/strong&gt; Applies when starting the Docker daemon. A comma-separated list of logging-related environment variables this daemon will accept. Used for advanced log tag options.&lt;/li&gt;
&lt;/ul&gt;

&lt;pre  style=&quot;font-family: 'Source Code Pro',monospace; white-space: pre-wrap; display: block; background-color: rgba(102,128,153,0.05); color: #333; word-wrap: break-word; font-size: .9em; background: #f6f6f6; line-height: 1.6; margin: 0 0 1.1em; padding: 0; border: 0; border-radius: 5px; text-align: start; word-break: break-all;&quot;&gt;&lt;code  style=&quot;font-family: 'Source Code Pro',monospace; font-size: inherit; background-color: transparent; white-space: pre-wrap; border-radius: 0; color: #f8f8f2; display: block; overflow-x: auto; background: #23241f; padding: 1.3em 2em;&quot;&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;--&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;log&lt;/span&gt;-opt &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;env&lt;/span&gt;=os,customer
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;blockquote style=&quot;padding: 15px 20px; margin: 0 0 1.1em; border-left: 5px solid rgba(102,128,153,0.075); border-left-width: 10px; background-color: rgba(102,128,153,0.05); border-top-right-radius: 5px; border-bottom-right-radius: 5px;&quot;&gt;
  &lt;p style=&quot;margin: 0 0 1.1em; font-size: 1em; font-weight: 300; margin-bottom: 0; line-height: 1.6;&quot;&gt;If you want to learn more about docker logging driver and configuration, you can checkout this page &lt;a href=&quot;https://docs.docker.com/engine/admin/logging/overview/&quot; target=&quot;_blank&quot; style=&quot;background: transparent; color: #1980e6; text-decoration: none;&quot;&gt;https://docs.docker.com/engine/admin/logging/overview/&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2 style=&quot;font-family: inherit; font-weight: bold; line-height: 1.1; color: inherit; margin-top: 21px; margin-bottom: 10.5px; font-size: 34.4px; margin: 1.2em 0 .6em 0; text-align: start;&quot;&gt;Logrotate&lt;/h2&gt;

&lt;p style=&quot;margin: 0 0 1.1em; line-height: 1.6;&quot;&gt;If you prefer that your host manage logs via logrotate rather than via container definition.&lt;/p&gt;



&lt;pre  style=&quot;font-family: 'Source Code Pro',monospace; white-space: pre-wrap; display: block; background-color: rgba(102,128,153,0.05); color: #333; word-wrap: break-word; font-size: .9em; background: #f6f6f6; line-height: 1.6; margin: 0 0 1.1em; padding: 0; border: 0; border-radius: 5px; text-align: start; word-break: break-all;&quot;&gt;&lt;code  style=&quot;font-family: 'Source Code Pro',monospace; font-size: inherit; background-color: transparent; white-space: pre-wrap; border-radius: 0; color: #f8f8f2; display: block; overflow-x: auto; background: #23241f; padding: 1.3em 2em;&quot;&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;vim /etc/logrotate.d/docker
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;



&lt;pre  style=&quot;font-family: 'Source Code Pro',monospace; white-space: pre-wrap; display: block; background-color: rgba(102,128,153,0.05); color: #333; word-wrap: break-word; font-size: .9em; background: #f6f6f6; line-height: 1.6; margin: 0 0 1.1em; padding: 0; border: 0; border-radius: 5px; text-align: start; word-break: break-all;&quot;&gt;&lt;code  style=&quot;font-family: 'Source Code Pro',monospace; font-size: inherit; background-color: transparent; white-space: pre-wrap; border-radius: 0; color: #f8f8f2; display: block; overflow-x: auto; background: #23241f; padding: 1.3em 2em;&quot;&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;/var/&lt;span  style=&quot;display: inline; line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #66d9ef;&quot;&gt;lib&lt;/span&gt;/&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f8f8f2;&quot;&gt;docker&lt;/span&gt;/&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f8f8f2;&quot;&gt;containers&lt;/span&gt;/*/*.&lt;span  style=&quot;display: inline; line-height: 1.6; color: #a6e22e; font-style: italic;&quot;&gt;log&lt;/span&gt; {&lt;/span&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;  rotate &lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;7&lt;/span&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;  daily
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;  compress
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;  size=&lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;1&lt;/span&gt;M
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;  missingok
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;  delaycompress
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;  copytruncate
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;}
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;p style=&quot;margin: 0 0 1.1em; line-height: 1.6;&quot;&gt;And then&lt;/p&gt;



&lt;pre  style=&quot;font-family: 'Source Code Pro',monospace; white-space: pre-wrap; display: block; background-color: rgba(102,128,153,0.05); color: #333; word-wrap: break-word; font-size: .9em; background: #f6f6f6; line-height: 1.6; margin: 0 0 1.1em; padding: 0; border: 0; border-radius: 5px; text-align: start; word-break: break-all;&quot;&gt;&lt;code  style=&quot;font-family: 'Source Code Pro',monospace; font-size: inherit; background-color: transparent; white-space: pre-wrap; border-radius: 0; color: #f8f8f2; display: block; overflow-x: auto; background: #23241f; padding: 1.3em 2em;&quot;&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;logrotate -fv &lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;/etc/&lt;/span&gt;logrotate.d&lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;/docker&lt;/span&gt;
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;center style='display:none'&gt;%23%20Docker%20and%20logs%0A%0A@%28Postach.io%29%5Bdocker%2C%20tips%2C%20logs%2C%20published%5D%0A%0A%21%5BAlt%20text%5D%28./docker-tribe.png%29%0A%0A%23%23%20How%20docker%20logging%20works%20%3F%0A%0AIt%27s%20very%20simple%2C%20to%20log%20from%20a%20container%2C%20you%20have%20to%20write%20in%20%60stdout%60%20%21%0A%0A%23%23%20Where%20container%20logs%20are%20sent%20%3F%20How%20can%20I%20see%20it%20%3F%0A%0AIt%27s%20a%20best%20practice%20to%20log%20on%20%60stdout%60%20from%20a%20container%2C%20it%27s%20an%20unified%20interface%20and%20directly%20available%20from%20%60docker%20logs%20-f%20%5Bcontainer%5D%60%20or%20through%20%60docker-compose%20logs%20-f%60.%20Howerver%20docker%20save%20the%20output%20produced%20by%20containers%20in%20%60/var/lib/docker/containers/%5BCONTAINER%20ID%5D/%5BCONTAINER_ID%5D-json.log%60%20by%20default.%20Json%20file%20is%20the%20default%20log%20driver%2C%20the%20most%20easier.%0A%0ADocker%20many%20built%20in%20log%20driver%20like%20as%20following%20%3A%20%0A%0A*%20**none%3A**%09No%20logs%20will%20be%20available%20for%20the%20container%20and%20docker%20logs%20will%20not%20return%20any%20output.%09%20%0A*%20**json-file%3A**%09The%20logs%20are%20formatted%20as%20JSON.%20The%20default%20logging%20driver%20for%20Docker.%09%20%0A*%20**syslog%3A**%09Writes%20logging%20messages%20to%20the%20syslog%20facility.%20The%20syslog%20daemon%20must%20be%20running%20on%20the%20host%20machine.%09%20%0A*%20**journald%3A**%09Writes%20log%20messages%20to%20journald.%20The%20journald%20daemon%20must%20be%20running%20on%20the%20host%20machine.%09%20%0A*%20**gelf%3A**%09Writes%20log%20messages%20to%20a%20Graylog%20Extended%20Log%20Format%20%28GELF%29%20endpoint%20such%20as%20Graylog%20or%20Logstash.%09%20%0A*%20**fluentd%3A**%09Writes%20log%20messages%20to%20fluentd%20%28forward%20input%29.%20The%20fluentd%20daemon%20must%20be%20running%20on%20the%20host%20machine.%09%20%0A*%20**awslogs%3A**%09Writes%20log%20messages%20to%20Amazon%20CloudWatch%20Logs.%09%20%0A*%20**splunk%3A**%09Writes%20log%20messages%20to%20splunk%20using%20the%20HTTP%20Event%20Collector.%09%20%0A*%20**etwlogs%3A**%09Writes%20log%20messages%20as%20Event%20Tracing%20for%20Windows%20%28ETW%29%20events.%20Only%20available%20on%20Windows%20platforms.%09%20%0A*%20**gcplogs%3A**%09Writes%20log%20messages%20to%20Google%20Cloud%20Platform%20%28GCP%29%20Logging.%09%20%0A*%20**nats%3A**%09NATS%20logging%20driver%20for%20Docker.%20Publishes%20log%20entries%20to%20a%20NATS%20server.%0A%0A%0A%60docker%20logs%60%20command%20is%20only%20available%20with%20%60json-file%60%20and%20%60journald%60%2C%20than%20mean%20you%20need%20to%20bring%20your%20infrastructure%20to%20visualize%20your%20logs%21%0A%0AWith%20%60json-file%60%20driver%20you%20will%20out%20of%20disk%20space%2C%20mostly%20if%20you%20work%20with%20worker%20%28or%20application%29%20which%20produce%20a%20huge%20amount%20of%20logs.%20You%20specify%20some%20parameters%20in%20order%20to%20avoid%20that.%20%0A%0A*%20**max-size**%20The%20maximum%20size%20of%20the%20log%20before%20it%20is%20rolled.%20A%20positive%20integer%20plus%20a%20modifier%20representing%20the%20unit%20of%20measure%20%28k%2C%20m%2C%20or%20g%29.%0A%0A%60%60%60%0A--log-opt%20max-size%3D10m%0A%60%60%60%0A*%20**max-file**%20The%20maximum%20number%20of%20log%20files%20that%20can%20be%20present.%20If%20rolling%20the%20logs%20creates%20excess%20files%2C%20the%20oldest%20file%20is%20removed.%20**Only%20effective**%20when%20max-size%20**is%20also%20set**.%20A%20positive%20integer.%0A%0A%60%60%60%0A--log-opt%20max-file%3D3%0A%60%60%60%0A%0A*%20**labels**%20Applies%20when%20starting%20the%20Docker%20daemon.%20A%20comma-separated%20list%20of%20logging-related%20labels%20this%20daemon%20will%20accept.%20Used%20for%20advanced%20log%20tag%20options.%0A%0A%60%60%60%0A--log-opt%20labels%3Dproduction_status%2Cgeo%0A%60%60%60%0A%0A*%20**env**%20Applies%20when%20starting%20the%20Docker%20daemon.%20A%20comma-separated%20list%20of%20logging-related%20environment%20variables%20this%20daemon%20will%20accept.%20Used%20for%20advanced%20log%20tag%20options.%0A%0A%60%60%60%0A--log-opt%20env%3Dos%2Ccustomer%0A%60%60%60%0A%20%20%20%0A%3E%20%20If%20you%20want%20to%20learn%20more%20about%20docker%20logging%20driver%20and%20configuration%2C%20you%20can%20checkout%20this%20page%20https%3A//docs.docker.com/engine/admin/logging/overview/%0A%0A%23%23%20Logrotate%0A%0AIf%20you%20prefer%20that%20your%20host%20manage%20logs%20via%20logrotate%20rather%20than%20via%20container%20definition.%0A%0A%60%60%60cmd%0Avim%20/etc/logrotate.d/docker%0A%60%60%60%0A%0A%60%60%60%0A/var/lib/docker/containers/*/*.log%20%7B%0A%20%20rotate%207%0A%20%20daily%0A%20%20compress%0A%20%20size%3D1M%0A%20%20missingok%0A%20%20delaycompress%0A%20%20copytruncate%0A%7D%0A%60%60%60%0A%0AAnd%20then%0A%0A%60%60%60%0Alogrotate%20-fv%20/etc/logrotate.d/docker%0A%60%60%60&lt;/center&gt;&lt;br/&gt;&lt;/div&gt;
</content>
  </entry>
  <entry xml:base="http://prophet777.postach.io/feed.xml">
    <title type="text">PHP, Unicode and UTF-8 without hassles</title>
    <id>https://prophet777.postach.io/post/php-unicode-and-utf-8-without-hassles</id>
    <updated>2017-12-28T13:33:04.899000Z</updated>
    <published>2016-12-21T11:22:03Z</published>
    <link href="https://prophet777.postach.io/post/php-unicode-and-utf-8-without-hassles" />
    <author>
      <name>prophet777</name>
    </author>
    <category term="utf-8" />
    <category term="php" />
    <content type="html">&lt;div&gt;&lt;del style=&quot;position:relative;display:block;z-index:10;&quot;&gt;&lt;a  style=&quot;position: absolute;color: #FFF;text-decoration: none;font-size: 12px;height: 25px;border-radius: 0;margin-top: -20px;right: 15px;background: rgba(0, 0, 0, 0);border-left: 10px solid #BB3A34;border-right: 10px solid #BB3A34;border-bottom: 5px solid rgba(0, 0, 0, 0);width: 0;text-indent:-100000px;&quot; href=&quot;http://marxi.co/#/?provider=evernote_int&amp;guid=c04d50f2-4f1f-41a8-b220-49d2b79f075d&amp;notebook=Postach.io&quot;&gt;Edit&lt;/a&gt;&lt;/del&gt;&lt;div  style=&quot;color: #2c3f51; line-height: 1.6;&quot;&gt;
                        
                    



&lt;h2 style=&quot;font-family: inherit; font-weight: bold; line-height: 1.1; color: inherit; margin-top: 21px; margin-bottom: 10.5px; font-size: 34.4px; margin: 1.2em 0 .6em 0; text-align: start;&quot;&gt;PHP, Unicode and UTF-8 without hassles&lt;/h2&gt;

&lt;p style=&quot;margin: 0 0 1.1em; line-height: 1.6;&quot;/&gt;



&lt;p style=&quot;margin: 0 0 1.1em; line-height: 1.6;&quot;&gt;&lt;img src=&quot;https://cdn-images.postach.io/0ae34934-1fa7-4ba9-8006-c5903a09de37/c04d50f2-4f1f-41a8-b220-49d2b79f075d/d8b62075-df19-4d18-9edc-bcec1f50a085.png&quot;  longdesc=&quot;./php-unicode.png&quot; alt=&quot;Alt text&quot; style=&quot;border: 0; vertical-align: middle; max-width: 100%;&quot;/&gt;&lt;/p&gt;



&lt;h3 style=&quot;font-family: inherit; font-weight: bold; color: inherit; margin-top: 21px; margin-bottom: 10.5px; font-size: 27.2px; margin: 1.2em 0 .6em 0; text-align: start; line-height: 1.6;&quot;&gt;Enable mbstring in PHP&lt;/h3&gt;

&lt;p style=&quot;margin: 0 0 1.1em; line-height: 1.6;&quot;&gt;PHP &lt;strong style=&quot;font-weight: bold; line-height: 1.6;&quot;&gt;doesn’t natively support&lt;/strong&gt; unicode but it’s &lt;strong style=&quot;font-weight: bold; line-height: 1.6;&quot;&gt;compatible&lt;/strong&gt;, you can check if multibytes functions are available.&lt;/p&gt;



&lt;pre  style=&quot;font-family: 'Source Code Pro',monospace; white-space: pre-wrap; display: block; background-color: rgba(102,128,153,0.05); color: #333; word-wrap: break-word; font-size: .9em; background: #f6f6f6; line-height: 1.6; margin: 0 0 1.1em; padding: 0; border: 0; border-radius: 5px; text-align: start; word-break: break-all;&quot;&gt;&lt;code  style=&quot;font-family: 'Source Code Pro',monospace; font-size: inherit; background-color: transparent; white-space: pre-wrap; border-radius: 0; color: #f8f8f2; display: block; overflow-x: auto; background: #23241f; padding: 1.3em 2em;&quot;&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;php -m | grep mbstring
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;p style=&quot;margin: 0 0 1.1em; line-height: 1.6;&quot;&gt;You can enable it with &lt;code style=&quot;font-family: 'Source Code Pro',monospace; font-size: .9em; padding: 2px 4px; color: #c7254e; background-color: #f9f2f4; white-space: normal; border-radius: 4px;&quot;&gt;sudo apt-get install php7.0-mbstring&lt;/code&gt; or at compile time by adding this flag &lt;code style=&quot;font-family: 'Source Code Pro',monospace; font-size: .9em; padding: 2px 4px; color: #c7254e; background-color: #f9f2f4; white-space: normal; border-radius: 4px;&quot;&gt;--enable-mbstring&lt;/code&gt;. More info &lt;a href=&quot;http://php.net/manual/en/mbstring.installation.php&quot; target=&quot;_blank&quot; style=&quot;background: transparent; color: #1980e6; text-decoration: none;&quot;&gt;here&lt;/a&gt;. If you can’t install mbstring via those ways, you can use the &lt;strong style=&quot;font-weight: bold; line-height: 1.6;&quot;&gt;polyfill&lt;/strong&gt; provided by symfony. &lt;/p&gt;

&lt;blockquote style=&quot;padding: 15px 20px; margin: 0 0 1.1em; border-left: 5px solid rgba(102,128,153,0.075); border-left-width: 10px; background-color: rgba(102,128,153,0.05); border-top-right-radius: 5px; border-bottom-right-radius: 5px;&quot;&gt;
  &lt;p style=&quot;margin: 0 0 1.1em; font-size: 1em; font-weight: 300; margin-bottom: 0; line-height: 1.6;&quot;&gt;&lt;strong style=&quot;font-weight: bold; line-height: 1.6;&quot;&gt;composer require symfony/polyfill-mbstring&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p style=&quot;margin: 0 0 1.1em; line-height: 1.6;&quot;&gt;PHP multibyte functions are documented here &lt;a href=&quot;http://php.net/manual/en/book.mbstring.php&quot; target=&quot;_blank&quot; style=&quot;background: transparent; color: #1980e6; text-decoration: none;&quot;&gt;mb_*&lt;/a&gt;&lt;/p&gt;

&lt;h3 style=&quot;font-family: inherit; font-weight: bold; color: inherit; margin-top: 21px; margin-bottom: 10.5px; font-size: 27.2px; margin: 1.2em 0 .6em 0; text-align: start; line-height: 1.6;&quot;&gt;UTF-8 and PHP&lt;/h3&gt;



&lt;pre  style=&quot;font-family: 'Source Code Pro',monospace; white-space: pre-wrap; display: block; background-color: rgba(102,128,153,0.05); color: #333; word-wrap: break-word; font-size: .9em; background: #f6f6f6; line-height: 1.6; margin: 0 0 1.1em; padding: 0; border: 0; border-radius: 5px; text-align: start; word-break: break-all;&quot;&gt;&lt;code  style=&quot;font-family: 'Source Code Pro',monospace; font-size: inherit; background-color: transparent; white-space: pre-wrap; border-radius: 0; color: #f8f8f2; display: block; overflow-x: auto; background: #23241f; padding: 1.3em 2em;&quot;&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;php&lt;/span&gt; -r &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;&quot;echo ini_get('default_charset');&quot;&lt;/span&gt; 
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;blockquote style=&quot;padding: 15px 20px; margin: 0 0 1.1em; border-left: 5px solid rgba(102,128,153,0.075); border-left-width: 10px; background-color: rgba(102,128,153,0.05); border-top-right-radius: 5px; border-bottom-right-radius: 5px;&quot;&gt;
  &lt;p style=&quot;margin: 0 0 1.1em; font-size: 1em; font-weight: 300; margin-bottom: 0; line-height: 1.6;&quot;&gt;If you use &lt;strong style=&quot;font-weight: bold; line-height: 1.6;&quot;&gt;PHP EXIF&lt;/strong&gt; extension you can also check &lt;code style=&quot;font-family: 'Source Code Pro',monospace; font-size: .9em; padding: 2px 4px; color: #c7254e; background-color: #f9f2f4; white-space: normal; border-radius: 4px;&quot;&gt;php -r &quot;echo ini_get('exif.encode_unicode');&quot;&lt;/code&gt; &lt;/p&gt;
&lt;/blockquote&gt;



&lt;h3 style=&quot;font-family: inherit; font-weight: bold; color: inherit; margin-top: 21px; margin-bottom: 10.5px; font-size: 27.2px; margin: 1.2em 0 .6em 0; text-align: start; line-height: 1.6;&quot;&gt;Make you application UTF-8 ready !&lt;/h3&gt;



&lt;h5 style=&quot;font-family: inherit; font-weight: bold; color: inherit; margin-top: 10.5px; margin-bottom: 10.5px; font-size: 16px; margin: 1.2em 0 .6em 0; text-align: start; line-height: 1.6;&quot;&gt;HTML&lt;/h5&gt;



&lt;pre  style=&quot;font-family: 'Source Code Pro',monospace; white-space: pre-wrap; display: block; background-color: rgba(102,128,153,0.05); color: #333; word-wrap: break-word; font-size: .9em; background: #f6f6f6; line-height: 1.6; margin: 0 0 1.1em; padding: 0; border: 0; border-radius: 5px; text-align: start; word-break: break-all;&quot;&gt;&lt;code  style=&quot;font-family: 'Source Code Pro',monospace; font-size: inherit; background-color: transparent; white-space: pre-wrap; border-radius: 0; color: #f8f8f2; display: block; overflow-x: auto; background: #23241f; padding: 1.3em 2em;&quot;&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f8f8f2;&quot;&gt;&lt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;meta&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;http-equiv&lt;/span&gt;=&lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;&quot;Content-Type&quot;&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;content&lt;/span&gt;=&lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;&quot;text/html; charset=utf-8&quot;&lt;/span&gt; /&gt;&lt;/span&gt;
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;



&lt;h5 style=&quot;font-family: inherit; font-weight: bold; color: inherit; margin-top: 10.5px; margin-bottom: 10.5px; font-size: 16px; margin: 1.2em 0 .6em 0; text-align: start; line-height: 1.6;&quot;&gt;HTTP&lt;/h5&gt;



&lt;pre  style=&quot;font-family: 'Source Code Pro',monospace; white-space: pre-wrap; display: block; background-color: rgba(102,128,153,0.05); color: #333; word-wrap: break-word; font-size: .9em; background: #f6f6f6; line-height: 1.6; margin: 0 0 1.1em; padding: 0; border: 0; border-radius: 5px; text-align: start; word-break: break-all;&quot;&gt;&lt;code  style=&quot;font-family: 'Source Code Pro',monospace; font-size: inherit; background-color: transparent; white-space: pre-wrap; border-radius: 0; color: #f8f8f2; display: block; overflow-x: auto; background: #23241f; padding: 1.3em 2em;&quot;&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;Content-Type&lt;/span&gt;: text/html; charset=utf-8
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;



&lt;h5 style=&quot;font-family: inherit; font-weight: bold; color: inherit; margin-top: 10.5px; margin-bottom: 10.5px; font-size: 16px; margin: 1.2em 0 .6em 0; text-align: start; line-height: 1.6;&quot;&gt;PHP PDO&lt;/h5&gt;



&lt;pre  style=&quot;font-family: 'Source Code Pro',monospace; white-space: pre-wrap; display: block; background-color: rgba(102,128,153,0.05); color: #333; word-wrap: break-word; font-size: .9em; background: #f6f6f6; line-height: 1.6; margin: 0 0 1.1em; padding: 0; border: 0; border-radius: 5px; text-align: start; word-break: break-all;&quot;&gt;&lt;code  style=&quot;font-family: 'Source Code Pro',monospace; font-size: inherit; background-color: transparent; white-space: pre-wrap; border-radius: 0; color: #f8f8f2; display: block; overflow-x: auto; background: #23241f; padding: 1.3em 2em;&quot;&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;$dbh = &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;new&lt;/span&gt; PDO(&lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;'mysql:host=localhost;dbname=test'&lt;/span&gt;, $user, $pass);
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;$dbh-&gt;exec(&lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;&quot;SET CHARACTER SET utf8&quot;&lt;/span&gt;);
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;p style=&quot;margin: 0 0 1.1em; line-height: 1.6;&quot;&gt;&lt;strong style=&quot;font-weight: bold; line-height: 1.6;&quot;&gt;OR&lt;/strong&gt;&lt;/p&gt;



&lt;pre  style=&quot;font-family: 'Source Code Pro',monospace; white-space: pre-wrap; display: block; background-color: rgba(102,128,153,0.05); color: #333; word-wrap: break-word; font-size: .9em; background: #f6f6f6; line-height: 1.6; margin: 0 0 1.1em; padding: 0; border: 0; border-radius: 5px; text-align: start; word-break: break-all;&quot;&gt;&lt;code  style=&quot;font-family: 'Source Code Pro',monospace; font-size: inherit; background-color: transparent; white-space: pre-wrap; border-radius: 0; color: #f8f8f2; display: block; overflow-x: auto; background: #23241f; padding: 1.3em 2em;&quot;&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;$dbh = &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;new&lt;/span&gt; PDO(&lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;'mysql:host=localhost;dbname=test'&lt;/span&gt;, $user, $pass, &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;array&lt;/span&gt;(
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;    PDO::MYSQL_ATTR_INIT_COMMAND =&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;&quot;SET NAMES utf8&quot;&lt;/span&gt;)
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;);
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;p style=&quot;margin: 0 0 1.1em; line-height: 1.6;&quot;&gt;&lt;strong style=&quot;font-weight: bold; line-height: 1.6;&quot;&gt;Enforce UTF-8&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote style=&quot;padding: 15px 20px; margin: 0 0 1.1em; border-left: 5px solid rgba(102,128,153,0.075); border-left-width: 10px; background-color: rgba(102,128,153,0.05); border-top-right-radius: 5px; border-bottom-right-radius: 5px;&quot;&gt;
  &lt;p style=&quot;margin: 0 0 1.1em; font-size: 1em; font-weight: 300; margin-bottom: 0; line-height: 1.6;&quot;&gt;composer require &lt;code style=&quot;font-family: 'Source Code Pro',monospace; font-size: .9em; padding: 2px 4px; color: #c7254e; background-color: #f9f2f4; white-space: normal; border-radius: 4px;&quot;&gt;patchwork/utf8&lt;/code&gt; &lt;/p&gt;
&lt;/blockquote&gt;

&lt;pre  style=&quot;font-family: 'Source Code Pro',monospace; white-space: pre-wrap; display: block; background-color: rgba(102,128,153,0.05); color: #333; word-wrap: break-word; font-size: .9em; background: #f6f6f6; line-height: 1.6; margin: 0 0 1.1em; padding: 0; border: 0; border-radius: 5px; text-align: start; word-break: break-all;&quot;&gt;&lt;code  style=&quot;font-family: 'Source Code Pro',monospace; font-size: inherit; background-color: transparent; white-space: pre-wrap; border-radius: 0; color: #f8f8f2; display: block; overflow-x: auto; background: #23241f; padding: 1.3em 2em;&quot;&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;\Patchwork\Utf8\Bootup::initAll();
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;\Patchwork\Utf8\Bootup::filterRequestUri();
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;\Patchwork\Utf8\Bootup::filterRequestInputs();
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;mb_internal_encoding(&lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;'UTF-8'&lt;/span&gt;);
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;mb_http_output(&lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;'UTF-8'&lt;/span&gt;);
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;blockquote style=&quot;padding: 15px 20px; margin: 0 0 1.1em; border-left: 5px solid rgba(102,128,153,0.075); border-left-width: 10px; background-color: rgba(102,128,153,0.05); border-top-right-radius: 5px; border-bottom-right-radius: 5px;&quot;&gt;
  &lt;p style=&quot;margin: 0 0 1.1em; font-size: 1em; font-weight: 300; margin-bottom: 0; line-height: 1.6;&quot;&gt;&lt;strong style=&quot;font-weight: bold; line-height: 1.6;&quot;&gt;Never use&lt;/strong&gt; &lt;a href=&quot;http://php.net/manual/fr/function.utf8-decode.php&quot; target=&quot;_blank&quot; style=&quot;background: transparent; color: #1980e6; text-decoration: none;&quot;&gt;utf8_decode()&lt;/a&gt; and &lt;a href=&quot;http://php.net/manual/fr/function.utf8-encode.php&quot; target=&quot;_blank&quot; style=&quot;background: transparent; color: #1980e6; text-decoration: none;&quot;&gt;utf8_encode()&lt;/a&gt; in your application.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p style=&quot;margin: 0 0 1.1em; line-height: 1.6;&quot;&gt;They are misspelled, they only encode and decode between &lt;code style=&quot;font-family: 'Source Code Pro',monospace; font-size: .9em; padding: 2px 4px; color: #c7254e; background-color: #f9f2f4; white-space: normal; border-radius: 4px;&quot;&gt;ISO-8859-1&lt;/code&gt; and &lt;code style=&quot;font-family: 'Source Code Pro',monospace; font-size: .9em; padding: 2px 4px; color: #c7254e; background-color: #f9f2f4; white-space: normal; border-radius: 4px;&quot;&gt;UTF-8&lt;/code&gt; think about &lt;code style=&quot;font-family: 'Source Code Pro',monospace; font-size: .9em; padding: 2px 4px; color: #c7254e; background-color: #f9f2f4; white-space: normal; border-radius: 4px;&quot;&gt;iso88591_to_utf8&lt;/code&gt; for &lt;code style=&quot;font-family: 'Source Code Pro',monospace; font-size: .9em; padding: 2px 4px; color: #c7254e; background-color: #f9f2f4; white-space: normal; border-radius: 4px;&quot;&gt;utf8_decode&lt;/code&gt; and &lt;code style=&quot;font-family: 'Source Code Pro',monospace; font-size: .9em; padding: 2px 4px; color: #c7254e; background-color: #f9f2f4; white-space: normal; border-radius: 4px;&quot;&gt;utf8_to_iso88591&lt;/code&gt; for &lt;code style=&quot;font-family: 'Source Code Pro',monospace; font-size: .9em; padding: 2px 4px; color: #c7254e; background-color: #f9f2f4; white-space: normal; border-radius: 4px;&quot;&gt;utf8_encode&lt;/code&gt; .&lt;/p&gt;

&lt;p style=&quot;margin: 0 0 1.1em; line-height: 1.6;&quot;&gt;If you want convert to another charset (it’s called &lt;strong style=&quot;font-weight: bold; line-height: 1.6;&quot;&gt;transliteration&lt;/strong&gt;) you can transliterate with &lt;a href=&quot;http://php.net/manual/fr/function.iconv.php&quot; target=&quot;_blank&quot; style=&quot;background: transparent; color: #1980e6; text-decoration: none;&quot;&gt;iconv&lt;/a&gt;&lt;/p&gt;

&lt;pre  style=&quot;font-family: 'Source Code Pro',monospace; white-space: pre-wrap; display: block; background-color: rgba(102,128,153,0.05); color: #333; word-wrap: break-word; font-size: .9em; background: #f6f6f6; line-height: 1.6; margin: 0 0 1.1em; padding: 0; border: 0; border-radius: 5px; text-align: start; word-break: break-all;&quot;&gt;&lt;code  style=&quot;font-family: 'Source Code Pro',monospace; font-size: inherit; background-color: transparent; white-space: pre-wrap; border-radius: 0; color: #f8f8f2; display: block; overflow-x: auto; background: #23241f; padding: 1.3em 2em;&quot;&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;echo&lt;/span&gt; iconv(&lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;'UTF-8'&lt;/span&gt;, &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;'ASCII//TRANSLIT'&lt;/span&gt;, &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;'text'&lt;/span&gt;);
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f8f8f2;&quot;&gt;$string&lt;/span&gt; = &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;'€'&lt;/span&gt;;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;echo&lt;/span&gt; iconv(mb_detect_encoding(&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f8f8f2;&quot;&gt;$string&lt;/span&gt;), &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;'ASCII//TRANSLIT'&lt;/span&gt;, &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f8f8f2;&quot;&gt;$string&lt;/span&gt;);
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;center style='display:none'&gt;%23%23%20PHP%2C%20Unicode%20and%20UTF-8%20without%20hassles%0A%0A@%28Postach.io%29%5Butf-8%2C%20php%2C%20published%5D%0A%0A%21%5BAlt%20text%5D%28./php-unicode.png%29%0A%0A%23%23%23%20Enable%20mbstring%20in%20PHP%0APHP%20**doesn%27t%20natively%20support**%20unicode%20but%20it%27s%20**compatible**%2C%20you%20can%20check%20if%20multibytes%20functions%20are%20available.%0A%0A%60%60%60cmd%0Aphp%20-m%20%7C%20grep%20mbstring%0A%60%60%60%0AYou%20can%20enable%20it%20with%20%60sudo%20apt-get%20install%20php7.0-mbstring%60%20or%20at%20compile%20time%20by%20adding%20this%20flag%20%60--enable-mbstring%60.%20More%20info%20%5Bhere%5D%28http%3A//php.net/manual/en/mbstring.installation.php%29.%20If%20you%20can%27t%20install%20mbstring%20via%20those%20ways%2C%20you%20can%20use%20the%20**polyfill**%20provided%20by%20symfony.%20%0A%0A%3E%20**composer%20require%20symfony/polyfill-mbstring**%0A%0APHP%20multibyte%20functions%20are%20documented%20here%20%5Bmb_*%5D%28http%3A//php.net/manual/en/book.mbstring.php%29%0A%0A%23%23%23%20UTF-8%20and%20PHP%0A%0A%60%60%60%0Aphp%20-r%20%22echo%20ini_get%28%27default_charset%27%29%3B%22%20%0A%60%60%60%0A%0A%3E%20If%20you%20use%20**PHP%20EXIF**%20extension%20you%20can%20also%20check%20%60php%20-r%20%22echo%20ini_get%28%27exif.encode_unicode%27%29%3B%22%20%60%20%0A%0A%0A%23%23%23%20Make%20you%20application%20UTF-8%20ready%20%21%0A%0A%23%23%23%23%23%20HTML%0A%60%60%60html%0A%3Cmeta%20http-equiv%3D%22Content-Type%22%20content%3D%22text/html%3B%20charset%3Dutf-8%22%20/%3E%0A%60%60%60%0A%0A%23%23%23%23%23%20HTTP%0A%60%60%60http%0AContent-Type%3A%20text/html%3B%20charset%3Dutf-8%0A%60%60%60%0A%0A%23%23%23%23%23%20PHP%20PDO%0A%60%60%60php%0A%24dbh%20%3D%20new%20PDO%28%27mysql%3Ahost%3Dlocalhost%3Bdbname%3Dtest%27%2C%20%24user%2C%20%24pass%29%3B%0A%24dbh-%3Eexec%28%22SET%20CHARACTER%20SET%20utf8%22%29%3B%0A%60%60%60%0A**OR**%0A%60%60%60php%0A%24dbh%20%3D%20new%20PDO%28%27mysql%3Ahost%3Dlocalhost%3Bdbname%3Dtest%27%2C%20%24user%2C%20%24pass%2C%20array%28%0A%09PDO%3A%3AMYSQL_ATTR_INIT_COMMAND%20%3D%3E%20%22SET%20NAMES%20utf8%22%29%0A%29%3B%0A%60%60%60%0A%0A**Enforce%20UTF-8**%0A%0A%3E%20composer%20require%20%60patchwork/utf8%60%20%0A%0A%60%60%60php%0A%5CPatchwork%5CUtf8%5CBootup%3A%3AinitAll%28%29%3B%0A%5CPatchwork%5CUtf8%5CBootup%3A%3AfilterRequestUri%28%29%3B%0A%5CPatchwork%5CUtf8%5CBootup%3A%3AfilterRequestInputs%28%29%3B%0Amb_internal_encoding%28%27UTF-8%27%29%3B%0Amb_http_output%28%27UTF-8%27%29%3B%0A%60%60%60%0A%0A%3E%20%20**Never%20use**%20%5Butf8_decode%28%29%5D%28http%3A//php.net/manual/fr/function.utf8-decode.php%29%20and%20%5Butf8_encode%28%29%5D%28http%3A//php.net/manual/fr/function.utf8-encode.php%29%20in%20your%20application.%0A%0AThey%20are%20misspelled%2C%20they%20only%20encode%20and%20decode%20between%20%60ISO-8859-1%60%20and%20%60UTF-8%60%20think%20about%20%60iso88591_to_utf8%60%20for%20%60utf8_decode%60%20and%20%60utf8_to_iso88591%60%20for%20%60utf8_encode%60%20.%0A%0AIf%20you%20want%20convert%20to%20another%20charset%20%28it%27s%20called%20**transliteration**%29%20you%20can%20transliterate%20with%20%5Biconv%5D%28http%3A//php.net/manual/fr/function.iconv.php%29%0A%0A%60%60%60%0Aecho%20iconv%28%27UTF-8%27%2C%20%27ASCII//TRANSLIT%27%2C%20%27text%27%29%3B%0A%0A%24string%20%3D%20%27%u20AC%27%3B%0Aecho%20iconv%28mb_detect_encoding%28%24string%29%2C%20%27ASCII//TRANSLIT%27%2C%20%24string%29%3B%0A%60%60%60%20%0A%0A&lt;/center&gt;&lt;br/&gt;&lt;/div&gt;
</content>
  </entry>
  <entry xml:base="http://prophet777.postach.io/feed.xml">
    <title type="text">PHP7, Stay up to date !</title>
    <id>https://prophet777.postach.io/post/php7-news</id>
    <updated>2017-12-28T13:45:13.993000Z</updated>
    <published>2016-12-20T14:51:32Z</published>
    <link href="https://prophet777.postach.io/post/php7-news" />
    <author>
      <name>prophet777</name>
    </author>
    <category term="features" />
    <category term="tips" />
    <category term="performance" />
    <category term="php" />
    <content type="html">&lt;div&gt;&lt;del style=&quot;position:relative;display:block;z-index:10;&quot;&gt;&lt;a  style=&quot;position: absolute;color: #FFF;text-decoration: none;font-size: 12px;height: 25px;border-radius: 0;margin-top: -20px;right: 15px;background: rgba(0, 0, 0, 0);border-left: 10px solid #BB3A34;border-right: 10px solid #BB3A34;border-bottom: 5px solid rgba(0, 0, 0, 0);width: 0;text-indent:-100000px;&quot; href=&quot;http://marxi.co/#/?provider=evernote_int&amp;guid=daf606d0-af9d-4c40-b4b4-837e96f9dcfd&amp;notebook=Postach.io&quot;&gt;Edit&lt;/a&gt;&lt;/del&gt;&lt;div  style=&quot;color: #2c3f51; line-height: 1.6;&quot;&gt;
                        
                    



&lt;h1 style=&quot;font-size: 41.6px; margin: 1.2em 0 .6em 0; font-family: inherit; font-weight: bold; line-height: 1.1; color: inherit; margin-top: 21px; margin-bottom: 10.5px; text-align: start;&quot;&gt;PHP7, Stay up to date !&lt;/h1&gt;

&lt;p style=&quot;margin: 0 0 1.1em; line-height: 1.6;&quot;/&gt;

&lt;hr style=&quot;-moz-box-sizing: content-box; box-sizing: content-box; height: 0; margin-top: 21px; margin-bottom: 21px; border: 0; border-top: 1px solid rgba(102,128,153,0.1); margin: 2em 0; line-height: 1.6;&quot;/&gt;

&lt;blockquote style=&quot;padding: 15px 20px; margin: 0 0 1.1em; border-left: 5px solid rgba(102,128,153,0.075); border-left-width: 10px; background-color: rgba(102,128,153,0.05); border-top-right-radius: 5px; border-bottom-right-radius: 5px;&quot;&gt;
  &lt;p style=&quot;margin: 0 0 1.1em; font-size: 1em; font-weight: 300; margin-bottom: 0; line-height: 1.6;&quot;&gt;TL;DR Full changelog &lt;a href=&quot;http://php.net/ChangeLog-7.php&quot; target=&quot;_blank&quot; style=&quot;background: transparent; color: #1980e6; text-decoration: none;&quot;&gt;http://php.net/ChangeLog-7.php&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2 style=&quot;font-family: inherit; font-weight: bold; line-height: 1.1; color: inherit; margin-top: 21px; margin-bottom: 10.5px; font-size: 34.4px; margin: 1.2em 0 .6em 0; text-align: start;&quot;&gt;New features&lt;/h2&gt;



&lt;h3 style=&quot;font-family: inherit; font-weight: bold; color: inherit; margin-top: 21px; margin-bottom: 10.5px; font-size: 27.2px; margin: 1.2em 0 .6em 0; text-align: start; line-height: 1.6;&quot;&gt;[7.1] HTTP/2 server push support in ext/curl&lt;/h3&gt;

&lt;blockquote style=&quot;padding: 15px 20px; margin: 0 0 1.1em; border-left: 5px solid rgba(102,128,153,0.075); border-left-width: 10px; background-color: rgba(102,128,153,0.05); border-top-right-radius: 5px; border-bottom-right-radius: 5px;&quot;&gt;
  &lt;p style=&quot;margin: 0 0 1.1em; font-size: 1em; font-weight: 300; margin-bottom: 0; line-height: 1.6;&quot;&gt;Support for server push has been added to the CURL extension (requires version 7.46 and above). This can be leveraged through the curl_multi_setopt() function with the new CURLMOPT_PUSHFUNCTION constant. The constants CURL_PUSH_OK and CURL_PUSH_DENY have also been added so that the execution of the server push callback can either be approved or denied.&lt;/p&gt;
&lt;/blockquote&gt;



&lt;pre  style=&quot;font-family: 'Source Code Pro',monospace; white-space: pre-wrap; display: block; background-color: rgba(102,128,153,0.05); color: #333; word-wrap: break-word; font-size: .9em; background: #f6f6f6; line-height: 1.6; margin: 0 0 1.1em; padding: 0; border: 0; border-radius: 5px; text-align: start; word-break: break-all;&quot;&gt;&lt;code  style=&quot;font-family: 'Source Code Pro',monospace; font-size: inherit; background-color: transparent; white-space: pre-wrap; border-radius: 0; color: #f8f8f2; display: block; overflow-x: auto; background: #23241f; padding: 1.3em 2em;&quot;&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;$mh = curl_multi_init();
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;curl_multi_setopt($mh, CURLMOPT_PIPELINING, CURLPIPE_MULTIPLEX);
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;curl_multi_setopt($mh, CURLMOPT_PUSHFUNCTION, $callback);
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;$callback = &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #66d9ef;&quot;&gt;function&lt;/span&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f8f8f2;&quot;&gt;($parent_ch, $pushed_ch, array $headers)&lt;/span&gt; &lt;/span&gt;{
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;    &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;return&lt;/span&gt; CURL_PUSH_OK;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;};
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;blockquote style=&quot;padding: 15px 20px; margin: 0 0 1.1em; border-left: 5px solid rgba(102,128,153,0.075); border-left-width: 10px; background-color: rgba(102,128,153,0.05); border-top-right-radius: 5px; border-bottom-right-radius: 5px;&quot;&gt;
  &lt;p style=&quot;margin: 0 0 1.1em; font-size: 1em; font-weight: 300; margin-bottom: 0; line-height: 1.6;&quot;&gt;[RFC] &lt;a href=&quot;https://wiki.php.net/rfc/curl_http2_push&quot; target=&quot;_blank&quot; style=&quot;background: transparent; color: #1980e6; text-decoration: none;&quot;&gt;https://wiki.php.net/rfc/curl_http2_push&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;



&lt;h3 style=&quot;font-family: inherit; font-weight: bold; color: inherit; margin-top: 21px; margin-bottom: 10.5px; font-size: 27.2px; margin: 1.2em 0 .6em 0; text-align: start; line-height: 1.6;&quot;&gt;[7.1] Asynchronous signal handling&lt;/h3&gt;

&lt;blockquote style=&quot;padding: 15px 20px; margin: 0 0 1.1em; border-left: 5px solid rgba(102,128,153,0.075); border-left-width: 10px; background-color: rgba(102,128,153,0.05); border-top-right-radius: 5px; border-bottom-right-radius: 5px;&quot;&gt;
  &lt;p style=&quot;margin: 0 0 1.1em; font-size: 1em; font-weight: 300; margin-bottom: 0; line-height: 1.6;&quot;&gt;A new function called pcntl_async_signals() has been introduced to enable asynchronous signal handling without using ticks (which introduce a lot of overhead).&lt;/p&gt;
&lt;/blockquote&gt;



&lt;pre  style=&quot;font-family: 'Source Code Pro',monospace; white-space: pre-wrap; display: block; background-color: rgba(102,128,153,0.05); color: #333; word-wrap: break-word; font-size: .9em; background: #f6f6f6; line-height: 1.6; margin: 0 0 1.1em; padding: 0; border: 0; border-radius: 5px; text-align: start; word-break: break-all;&quot;&gt;&lt;code  style=&quot;font-family: 'Source Code Pro',monospace; font-size: inherit; background-color: transparent; white-space: pre-wrap; border-radius: 0; color: #f8f8f2; display: block; overflow-x: auto; background: #23241f; padding: 1.3em 2em;&quot;&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;pcntl_async_signals(&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;true&lt;/span&gt;); &lt;span  style=&quot;display: inline; line-height: 1.6; color: #75715e;&quot;&gt;// turn on async signals&lt;/span&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;pcntl_signal(SIGHUP,  &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #66d9ef;&quot;&gt;function&lt;/span&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f8f8f2;&quot;&gt;($sig)&lt;/span&gt; &lt;/span&gt;{
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;    &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;echo&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;&quot;SIGHUP\n&quot;&lt;/span&gt;;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;});
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;posix_kill(posix_getpid(), SIGHUP);
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;blockquote style=&quot;padding: 15px 20px; margin: 0 0 1.1em; border-left: 5px solid rgba(102,128,153,0.075); border-left-width: 10px; background-color: rgba(102,128,153,0.05); border-top-right-radius: 5px; border-bottom-right-radius: 5px;&quot;&gt;
  &lt;p style=&quot;margin: 0 0 1.1em; font-size: 1em; font-weight: 300; margin-bottom: 0; line-height: 1.6;&quot;&gt;&lt;a href=&quot;https://github.com/Seldaek/signal-handler&quot; target=&quot;_blank&quot; style=&quot;background: transparent; color: #1980e6; text-decoration: none;&quot;&gt;https://github.com/Seldaek/signal-handler&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;



&lt;h3 style=&quot;font-family: inherit; font-weight: bold; color: inherit; margin-top: 21px; margin-bottom: 10.5px; font-size: 27.2px; margin: 1.2em 0 .6em 0; text-align: start; line-height: 1.6;&quot;&gt;[7.1] Convert callables to Closures with Closure::fromCallable()&lt;/h3&gt;



&lt;pre  style=&quot;font-family: 'Source Code Pro',monospace; white-space: pre-wrap; display: block; background-color: rgba(102,128,153,0.05); color: #333; word-wrap: break-word; font-size: .9em; background: #f6f6f6; line-height: 1.6; margin: 0 0 1.1em; padding: 0; border: 0; border-radius: 5px; text-align: start; word-break: break-all;&quot;&gt;&lt;code  style=&quot;font-family: 'Source Code Pro',monospace; font-size: inherit; background-color: transparent; white-space: pre-wrap; border-radius: 0; color: #f8f8f2; display: block; overflow-x: auto; background: #23241f; padding: 1.3em 2em;&quot;&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #66d9ef;&quot;&gt;class&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #a6e22e; font-style: italic;&quot;&gt;Test&lt;/span&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;{
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;    &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;public&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #66d9ef;&quot;&gt;function&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #a6e22e;&quot;&gt;exposeFunction&lt;/span&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f8f8f2;&quot;&gt;()&lt;/span&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;    {
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;        &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;return&lt;/span&gt; Closure::fromCallable([&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;$this&lt;/span&gt;, &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;'privateFunction'&lt;/span&gt;]);
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;    }
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;    &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;private&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #66d9ef;&quot;&gt;function&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #a6e22e;&quot;&gt;privateFunction&lt;/span&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f8f8f2;&quot;&gt;($param)&lt;/span&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;    {
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;        var_dump($param);
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;    }
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;}
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;$privFunc = (&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;new&lt;/span&gt; Test)-&gt;exposeFunction();
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;$privFunc(&lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;'some value'&lt;/span&gt;);
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;



&lt;h3 style=&quot;font-family: inherit; font-weight: bold; color: inherit; margin-top: 21px; margin-bottom: 10.5px; font-size: 27.2px; margin: 1.2em 0 .6em 0; text-align: start; line-height: 1.6;&quot;&gt;[7.1] Support for negative string offsets&lt;/h3&gt;

&lt;blockquote style=&quot;padding: 15px 20px; margin: 0 0 1.1em; border-left: 5px solid rgba(102,128,153,0.075); border-left-width: 10px; background-color: rgba(102,128,153,0.05); border-top-right-radius: 5px; border-bottom-right-radius: 5px;&quot;&gt;
  &lt;p style=&quot;margin: 0 0 1.1em; font-size: 1em; font-weight: 300; margin-bottom: 0; line-height: 1.6;&quot;&gt;Support for negative string offsets has been added to the string manipulation functions accepting offsets, as well as to string indexing with [] or {}. In such cases, a negative offset is interpreted as being an offset from the end of the string.&lt;/p&gt;
&lt;/blockquote&gt;



&lt;pre  style=&quot;font-family: 'Source Code Pro',monospace; white-space: pre-wrap; display: block; background-color: rgba(102,128,153,0.05); color: #333; word-wrap: break-word; font-size: .9em; background: #f6f6f6; line-height: 1.6; margin: 0 0 1.1em; padding: 0; border: 0; border-radius: 5px; text-align: start; word-break: break-all;&quot;&gt;&lt;code  style=&quot;font-family: 'Source Code Pro',monospace; font-size: inherit; background-color: transparent; white-space: pre-wrap; border-radius: 0; color: #f8f8f2; display: block; overflow-x: auto; background: #23241f; padding: 1.3em 2em;&quot;&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;var_dump(&lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;&quot;abcdef&quot;&lt;/span&gt;[&lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;-2&lt;/span&gt;]);
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;var_dump(strpos(&lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;&quot;aabbcc&quot;&lt;/span&gt;, &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;&quot;b&quot;&lt;/span&gt;, &lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;-3&lt;/span&gt;));
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;$string = &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;'bar'&lt;/span&gt;;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;echo&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;&quot;The last character of '$string' is '$string[-1]'.\n&quot;&lt;/span&gt;;
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;



&lt;pre  style=&quot;font-family: 'Source Code Pro',monospace; white-space: pre-wrap; display: block; background-color: rgba(102,128,153,0.05); color: #333; word-wrap: break-word; font-size: .9em; background: #f6f6f6; line-height: 1.6; margin: 0 0 1.1em; padding: 0; border: 0; border-radius: 5px; text-align: start; word-break: break-all;&quot;&gt;&lt;code  style=&quot;font-family: 'Source Code Pro',monospace; font-size: inherit; background-color: transparent; white-space: pre-wrap; border-radius: 0; color: #f8f8f2; display: block; overflow-x: auto; background: #23241f; padding: 1.3em 2em;&quot;&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;string&lt;/span&gt; (&lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;1&lt;/span&gt;) &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;&quot;e&quot;&lt;/span&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;int(&lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;3&lt;/span&gt;)
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;The &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;last&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;character&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;of&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;'bar'&lt;/span&gt; is &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;'r'&lt;/span&gt;.
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;



&lt;h3 style=&quot;font-family: inherit; font-weight: bold; color: inherit; margin-top: 21px; margin-bottom: 10.5px; font-size: 27.2px; margin: 1.2em 0 .6em 0; text-align: start; line-height: 1.6;&quot;&gt;[7.1] Support for keys in list()&lt;/h3&gt;



&lt;pre  style=&quot;font-family: 'Source Code Pro',monospace; white-space: pre-wrap; display: block; background-color: rgba(102,128,153,0.05); color: #333; word-wrap: break-word; font-size: .9em; background: #f6f6f6; line-height: 1.6; margin: 0 0 1.1em; padding: 0; border: 0; border-radius: 5px; text-align: start; word-break: break-all;&quot;&gt;&lt;code  style=&quot;font-family: 'Source Code Pro',monospace; font-size: inherit; background-color: transparent; white-space: pre-wrap; border-radius: 0; color: #f8f8f2; display: block; overflow-x: auto; background: #23241f; padding: 1.3em 2em;&quot;&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;$data = [
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;    [&lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;&quot;id&quot;&lt;/span&gt; =&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;1&lt;/span&gt;, &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;&quot;name&quot;&lt;/span&gt; =&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;'Tom'&lt;/span&gt;],
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;    [&lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;&quot;id&quot;&lt;/span&gt; =&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;2&lt;/span&gt;, &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;&quot;name&quot;&lt;/span&gt; =&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;'Fred'&lt;/span&gt;],
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;];
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #75715e;&quot;&gt;// list() style&lt;/span&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;list&lt;/span&gt;(&lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;&quot;id&quot;&lt;/span&gt; =&gt; $id1, &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;&quot;name&quot;&lt;/span&gt; =&gt; $name1) = $data[&lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;0&lt;/span&gt;];
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #75715e;&quot;&gt;// [] style&lt;/span&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;[&lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;&quot;id&quot;&lt;/span&gt; =&gt; $id1, &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;&quot;name&quot;&lt;/span&gt; =&gt; $name1] = $data[&lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;0&lt;/span&gt;];
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #75715e;&quot;&gt;// list() style&lt;/span&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;foreach&lt;/span&gt; ($data &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;as&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;list&lt;/span&gt;(&lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;&quot;id&quot;&lt;/span&gt; =&gt; $id, &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;&quot;name&quot;&lt;/span&gt; =&gt; $name)) {
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;    &lt;span  style=&quot;display: inline; line-height: 1.6; color: #75715e;&quot;&gt;// logic here with $id and $name&lt;/span&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;}
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #75715e;&quot;&gt;// [] style&lt;/span&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;foreach&lt;/span&gt; ($data &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;as&lt;/span&gt; [&lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;&quot;id&quot;&lt;/span&gt; =&gt; $id, &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;&quot;name&quot;&lt;/span&gt; =&gt; $name]) {
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;    &lt;span  style=&quot;display: inline; line-height: 1.6; color: #75715e;&quot;&gt;// logic here with $id and $name&lt;/span&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;}
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;



&lt;h3 style=&quot;font-family: inherit; font-weight: bold; color: inherit; margin-top: 21px; margin-bottom: 10.5px; font-size: 27.2px; margin: 1.2em 0 .6em 0; text-align: start; line-height: 1.6;&quot;&gt;[7.1] Multi catch exception handling&lt;/h3&gt;



&lt;pre  style=&quot;font-family: 'Source Code Pro',monospace; white-space: pre-wrap; display: block; background-color: rgba(102,128,153,0.05); color: #333; word-wrap: break-word; font-size: .9em; background: #f6f6f6; line-height: 1.6; margin: 0 0 1.1em; padding: 0; border: 0; border-radius: 5px; text-align: start; word-break: break-all;&quot;&gt;&lt;code  style=&quot;font-family: 'Source Code Pro',monospace; font-size: inherit; background-color: transparent; white-space: pre-wrap; border-radius: 0; color: #f8f8f2; display: block; overflow-x: auto; background: #23241f; padding: 1.3em 2em;&quot;&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;try&lt;/span&gt; {
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;    &lt;span  style=&quot;display: inline; line-height: 1.6; color: #75715e;&quot;&gt;// some code&lt;/span&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;} &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;catch&lt;/span&gt; (FirstException | SecondException $e) {
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;    &lt;span  style=&quot;display: inline; line-height: 1.6; color: #75715e;&quot;&gt;// handle first and second exceptions&lt;/span&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;}
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;



&lt;h3 style=&quot;font-family: inherit; font-weight: bold; color: inherit; margin-top: 21px; margin-bottom: 10.5px; font-size: 27.2px; margin: 1.2em 0 .6em 0; text-align: start; line-height: 1.6;&quot;&gt;[7.1] Iterable pseudo-type&lt;/h3&gt;



&lt;pre  style=&quot;font-family: 'Source Code Pro',monospace; white-space: pre-wrap; display: block; background-color: rgba(102,128,153,0.05); color: #333; word-wrap: break-word; font-size: .9em; background: #f6f6f6; line-height: 1.6; margin: 0 0 1.1em; padding: 0; border: 0; border-radius: 5px; text-align: start; word-break: break-all;&quot;&gt;&lt;code  style=&quot;font-family: 'Source Code Pro',monospace; font-size: inherit; background-color: transparent; white-space: pre-wrap; border-radius: 0; color: #f8f8f2; display: block; overflow-x: auto; background: #23241f; padding: 1.3em 2em;&quot;&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #66d9ef;&quot;&gt;function&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #a6e22e;&quot;&gt;iterator&lt;/span&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f8f8f2;&quot;&gt;(iterable $iter)&lt;/span&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;{
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;    &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;foreach&lt;/span&gt; ($iter &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;as&lt;/span&gt; $val) {
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;        &lt;span  style=&quot;display: inline; line-height: 1.6; color: #75715e;&quot;&gt;//&lt;/span&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;    }
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;}
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;



&lt;h3 style=&quot;font-family: inherit; font-weight: bold; color: inherit; margin-top: 21px; margin-bottom: 10.5px; font-size: 27.2px; margin: 1.2em 0 .6em 0; text-align: start; line-height: 1.6;&quot;&gt;[7.1] Class constant visibility&lt;/h3&gt;



&lt;pre  style=&quot;font-family: 'Source Code Pro',monospace; white-space: pre-wrap; display: block; background-color: rgba(102,128,153,0.05); color: #333; word-wrap: break-word; font-size: .9em; background: #f6f6f6; line-height: 1.6; margin: 0 0 1.1em; padding: 0; border: 0; border-radius: 5px; text-align: start; word-break: break-all;&quot;&gt;&lt;code  style=&quot;font-family: 'Source Code Pro',monospace; font-size: inherit; background-color: transparent; white-space: pre-wrap; border-radius: 0; color: #f8f8f2; display: block; overflow-x: auto; background: #23241f; padding: 1.3em 2em;&quot;&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #66d9ef;&quot;&gt;class&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #a6e22e; font-style: italic;&quot;&gt;ConstDemo&lt;/span&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;{
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;    &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;const&lt;/span&gt; PUBLIC_CONST_A = &lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;1&lt;/span&gt;;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;    &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;public&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;const&lt;/span&gt; PUBLIC_CONST_B = &lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;2&lt;/span&gt;;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;    &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;protected&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;const&lt;/span&gt; PROTECTED_CONST = &lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;3&lt;/span&gt;;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;    &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;private&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;const&lt;/span&gt; PRIVATE_CONST = &lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;4&lt;/span&gt;;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;}
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;



&lt;h3 style=&quot;font-family: inherit; font-weight: bold; color: inherit; margin-top: 21px; margin-bottom: 10.5px; font-size: 27.2px; margin: 1.2em 0 .6em 0; text-align: start; line-height: 1.6;&quot;&gt;[7.1] Void functions&lt;/h3&gt;



&lt;pre  style=&quot;font-family: 'Source Code Pro',monospace; white-space: pre-wrap; display: block; background-color: rgba(102,128,153,0.05); color: #333; word-wrap: break-word; font-size: .9em; background: #f6f6f6; line-height: 1.6; margin: 0 0 1.1em; padding: 0; border: 0; border-radius: 5px; text-align: start; word-break: break-all;&quot;&gt;&lt;code  style=&quot;font-family: 'Source Code Pro',monospace; font-size: inherit; background-color: transparent; white-space: pre-wrap; border-radius: 0; color: #f8f8f2; display: block; overflow-x: auto; background: #23241f; padding: 1.3em 2em;&quot;&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #66d9ef;&quot;&gt;function&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #a6e22e;&quot;&gt;swap&lt;/span&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f8f8f2;&quot;&gt;(&amp;$left, &amp;$right)&lt;/span&gt; : &lt;span  style=&quot;display: inline; line-height: 1.6; color: #a6e22e;&quot;&gt;void&lt;/span&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;{
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;    &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;if&lt;/span&gt; ($left === $right) {
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;        &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;return&lt;/span&gt;;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;    }
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;    $tmp = $left;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;    $left = $right;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;    $right = $tmp;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;}
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;$a = &lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;1&lt;/span&gt;;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;$b = &lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;2&lt;/span&gt;;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;var_dump(swap($a, $b), $a, $b);
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;



&lt;h3 style=&quot;font-family: inherit; font-weight: bold; color: inherit; margin-top: 21px; margin-bottom: 10.5px; font-size: 27.2px; margin: 1.2em 0 .6em 0; text-align: start; line-height: 1.6;&quot;&gt;[7.1] Symmetric array destructuring&lt;/h3&gt;



&lt;pre  style=&quot;font-family: 'Source Code Pro',monospace; white-space: pre-wrap; display: block; background-color: rgba(102,128,153,0.05); color: #333; word-wrap: break-word; font-size: .9em; background: #f6f6f6; line-height: 1.6; margin: 0 0 1.1em; padding: 0; border: 0; border-radius: 5px; text-align: start; word-break: break-all;&quot;&gt;&lt;code  style=&quot;font-family: 'Source Code Pro',monospace; font-size: inherit; background-color: transparent; white-space: pre-wrap; border-radius: 0; color: #f8f8f2; display: block; overflow-x: auto; background: #23241f; padding: 1.3em 2em;&quot;&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;$data = [
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;    [&lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;1&lt;/span&gt;, &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;'Tom'&lt;/span&gt;],
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;    [&lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;2&lt;/span&gt;, &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;'Fred'&lt;/span&gt;],
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;];
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #75715e;&quot;&gt;// list() style&lt;/span&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;list&lt;/span&gt;($id1, $name1) = $data[&lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;0&lt;/span&gt;];
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #75715e;&quot;&gt;// [] style&lt;/span&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;[$id1, $name1] = $data[&lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;0&lt;/span&gt;];
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #75715e;&quot;&gt;// list() style&lt;/span&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;foreach&lt;/span&gt; ($data &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;as&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;list&lt;/span&gt;($id, $name)) {
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;    &lt;span  style=&quot;display: inline; line-height: 1.6; color: #75715e;&quot;&gt;// logic here with $id and $name&lt;/span&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;}
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #75715e;&quot;&gt;// [] style&lt;/span&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;foreach&lt;/span&gt; ($data &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;as&lt;/span&gt; [$id, $name]) {
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;    &lt;span  style=&quot;display: inline; line-height: 1.6; color: #75715e;&quot;&gt;// logic here with $id and $name&lt;/span&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;}
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;



&lt;pre  style=&quot;font-family: 'Source Code Pro',monospace; white-space: pre-wrap; display: block; background-color: rgba(102,128,153,0.05); color: #333; word-wrap: break-word; font-size: .9em; background: #f6f6f6; line-height: 1.6; margin: 0 0 1.1em; padding: 0; border: 0; border-radius: 5px; text-align: start; word-break: break-all;&quot;&gt;&lt;code  style=&quot;font-family: 'Source Code Pro',monospace; font-size: inherit; background-color: transparent; white-space: pre-wrap; border-radius: 0; color: #f8f8f2; display: block; overflow-x: auto; background: #23241f; padding: 1.3em 2em;&quot;&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;null
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #a6e22e;&quot;&gt;int&lt;/span&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f8f8f2;&quot;&gt;(&lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;2&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #a6e22e;&quot;&gt;int&lt;/span&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f8f8f2;&quot;&gt;(&lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;1&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;



&lt;h3 style=&quot;font-family: inherit; font-weight: bold; color: inherit; margin-top: 21px; margin-bottom: 10.5px; font-size: 27.2px; margin: 1.2em 0 .6em 0; text-align: start; line-height: 1.6;&quot;&gt;[7.1] Nullable types&lt;/h3&gt;



&lt;pre  style=&quot;font-family: 'Source Code Pro',monospace; white-space: pre-wrap; display: block; background-color: rgba(102,128,153,0.05); color: #333; word-wrap: break-word; font-size: .9em; background: #f6f6f6; line-height: 1.6; margin: 0 0 1.1em; padding: 0; border: 0; border-radius: 5px; text-align: start; word-break: break-all;&quot;&gt;&lt;code  style=&quot;font-family: 'Source Code Pro',monospace; font-size: inherit; background-color: transparent; white-space: pre-wrap; border-radius: 0; color: #f8f8f2; display: block; overflow-x: auto; background: #23241f; padding: 1.3em 2em;&quot;&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #66d9ef;&quot;&gt;function&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #a6e22e;&quot;&gt;testReturn&lt;/span&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f8f8f2;&quot;&gt;()&lt;/span&gt;: ?&lt;span  style=&quot;display: inline; line-height: 1.6; color: #a6e22e;&quot;&gt;string&lt;/span&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;{
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;    &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;return&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;'elePHPant'&lt;/span&gt;;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;}
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;var_dump(testReturn());
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #66d9ef;&quot;&gt;function&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #a6e22e;&quot;&gt;testReturn&lt;/span&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f8f8f2;&quot;&gt;()&lt;/span&gt;: ?&lt;span  style=&quot;display: inline; line-height: 1.6; color: #a6e22e;&quot;&gt;string&lt;/span&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;{
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;    &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;return&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;null&lt;/span&gt;;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;}
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;var_dump(testReturn());
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #66d9ef;&quot;&gt;function&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #a6e22e;&quot;&gt;test&lt;/span&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f8f8f2;&quot;&gt;(?string $name)&lt;/span&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;{
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;    var_dump($name);
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;}
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;test(&lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;'elePHPant'&lt;/span&gt;);
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;test(&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;null&lt;/span&gt;);
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;test();
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;



&lt;pre  style=&quot;font-family: 'Source Code Pro',monospace; white-space: pre-wrap; display: block; background-color: rgba(102,128,153,0.05); color: #333; word-wrap: break-word; font-size: .9em; background: #f6f6f6; line-height: 1.6; margin: 0 0 1.1em; padding: 0; border: 0; border-radius: 5px; text-align: start; word-break: break-all;&quot;&gt;&lt;code  style=&quot;font-family: 'Source Code Pro',monospace; font-size: inherit; background-color: transparent; white-space: pre-wrap; border-radius: 0; color: #f8f8f2; display: block; overflow-x: auto; background: #23241f; padding: 1.3em 2em;&quot;&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;string&lt;/span&gt;(&lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;10&lt;/span&gt;) &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;&quot;elePHPant&quot;&lt;/span&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;NULL&lt;/span&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;string&lt;/span&gt;(&lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;10&lt;/span&gt;) &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;&quot;elePHPant&quot;&lt;/span&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;NULL&lt;/span&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;Uncaught &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;Error&lt;/span&gt;: Too few arguments &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;to&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;function&lt;/span&gt; test(), &lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;0&lt;/span&gt; passed &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;in&lt;/span&gt;...
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;



&lt;h3 style=&quot;font-family: inherit; font-weight: bold; color: inherit; margin-top: 21px; margin-bottom: 10.5px; font-size: 27.2px; margin: 1.2em 0 .6em 0; text-align: start; line-height: 1.6;&quot;&gt;[7.0] Scalar type declarations&lt;/h3&gt;



&lt;pre  style=&quot;font-family: 'Source Code Pro',monospace; white-space: pre-wrap; display: block; background-color: rgba(102,128,153,0.05); color: #333; word-wrap: break-word; font-size: .9em; background: #f6f6f6; line-height: 1.6; margin: 0 0 1.1em; padding: 0; border: 0; border-radius: 5px; text-align: start; word-break: break-all;&quot;&gt;&lt;code  style=&quot;font-family: 'Source Code Pro',monospace; font-size: inherit; background-color: transparent; white-space: pre-wrap; border-radius: 0; color: #f8f8f2; display: block; overflow-x: auto; background: #23241f; padding: 1.3em 2em;&quot;&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #75715e;&quot;&gt;&lt;?php&lt;/span&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;declare&lt;/span&gt;(strict_type=&lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;1&lt;/span&gt;);
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #66d9ef;&quot;&gt;function&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #a6e22e;&quot;&gt;test&lt;/span&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f8f8f2;&quot;&gt;(int $integer, bool $bool, floar $float, string $string)&lt;/span&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;{
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;}
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;



&lt;h3 style=&quot;font-family: inherit; font-weight: bold; color: inherit; margin-top: 21px; margin-bottom: 10.5px; font-size: 27.2px; margin: 1.2em 0 .6em 0; text-align: start; line-height: 1.6;&quot;&gt;[7.0] Return type declarations&lt;/h3&gt;



&lt;pre  style=&quot;font-family: 'Source Code Pro',monospace; white-space: pre-wrap; display: block; background-color: rgba(102,128,153,0.05); color: #333; word-wrap: break-word; font-size: .9em; background: #f6f6f6; line-height: 1.6; margin: 0 0 1.1em; padding: 0; border: 0; border-radius: 5px; text-align: start; word-break: break-all;&quot;&gt;&lt;code  style=&quot;font-family: 'Source Code Pro',monospace; font-size: inherit; background-color: transparent; white-space: pre-wrap; border-radius: 0; color: #f8f8f2; display: block; overflow-x: auto; background: #23241f; padding: 1.3em 2em;&quot;&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #75715e;&quot;&gt;&lt;?php&lt;/span&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #66d9ef;&quot;&gt;function&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #a6e22e;&quot;&gt;arraysSum&lt;/span&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f8f8f2;&quot;&gt;(array ...$arrays)&lt;/span&gt;: &lt;span  style=&quot;display: inline; line-height: 1.6; color: #a6e22e;&quot;&gt;array&lt;/span&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;{
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;    &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;return&lt;/span&gt; array_map(&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #66d9ef;&quot;&gt;function&lt;/span&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f8f8f2;&quot;&gt;(array $array)&lt;/span&gt;: &lt;span  style=&quot;display: inline; line-height: 1.6; color: #a6e22e;&quot;&gt;int&lt;/span&gt; &lt;/span&gt;{
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;        &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;return&lt;/span&gt; array_sum($array);
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;    }, $arrays);
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;}
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;



&lt;h3 style=&quot;font-family: inherit; font-weight: bold; color: inherit; margin-top: 21px; margin-bottom: 10.5px; font-size: 27.2px; margin: 1.2em 0 .6em 0; text-align: start; line-height: 1.6;&quot;&gt;[7.0] Null coalescing operator&lt;/h3&gt;



&lt;pre  style=&quot;font-family: 'Source Code Pro',monospace; white-space: pre-wrap; display: block; background-color: rgba(102,128,153,0.05); color: #333; word-wrap: break-word; font-size: .9em; background: #f6f6f6; line-height: 1.6; margin: 0 0 1.1em; padding: 0; border: 0; border-radius: 5px; text-align: start; word-break: break-all;&quot;&gt;&lt;code  style=&quot;font-family: 'Source Code Pro',monospace; font-size: inherit; background-color: transparent; white-space: pre-wrap; border-radius: 0; color: #f8f8f2; display: block; overflow-x: auto; background: #23241f; padding: 1.3em 2em;&quot;&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;$username = $_GET[&lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;'user'&lt;/span&gt;] ?? $_POST[&lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;'user'&lt;/span&gt;] ?? &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;'nobody'&lt;/span&gt;;
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;



&lt;h3 style=&quot;font-family: inherit; font-weight: bold; color: inherit; margin-top: 21px; margin-bottom: 10.5px; font-size: 27.2px; margin: 1.2em 0 .6em 0; text-align: start; line-height: 1.6;&quot;&gt;[7.0] Spaceship operator&lt;/h3&gt;



&lt;pre  style=&quot;font-family: 'Source Code Pro',monospace; white-space: pre-wrap; display: block; background-color: rgba(102,128,153,0.05); color: #333; word-wrap: break-word; font-size: .9em; background: #f6f6f6; line-height: 1.6; margin: 0 0 1.1em; padding: 0; border: 0; border-radius: 5px; text-align: start; word-break: break-all;&quot;&gt;&lt;code  style=&quot;font-family: 'Source Code Pro',monospace; font-size: inherit; background-color: transparent; white-space: pre-wrap; border-radius: 0; color: #f8f8f2; display: block; overflow-x: auto; background: #23241f; padding: 1.3em 2em;&quot;&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #75715e;&quot;&gt;&lt;?php&lt;/span&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #75715e;&quot;&gt;// Integers&lt;/span&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;echo&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;1&lt;/span&gt; &lt;=&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;1&lt;/span&gt;; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #75715e;&quot;&gt;// 0&lt;/span&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;echo&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;1&lt;/span&gt; &lt;=&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;2&lt;/span&gt;; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #75715e;&quot;&gt;// -1&lt;/span&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;echo&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;2&lt;/span&gt; &lt;=&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;1&lt;/span&gt;; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #75715e;&quot;&gt;// 1&lt;/span&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #75715e;&quot;&gt;// Floats&lt;/span&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;echo&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;1.5&lt;/span&gt; &lt;=&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;1.5&lt;/span&gt;; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #75715e;&quot;&gt;// 0&lt;/span&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;echo&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;1.5&lt;/span&gt; &lt;=&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;2.5&lt;/span&gt;; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #75715e;&quot;&gt;// -1&lt;/span&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;echo&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;2.5&lt;/span&gt; &lt;=&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;1.5&lt;/span&gt;; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #75715e;&quot;&gt;// 1&lt;/span&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #75715e;&quot;&gt;// Strings&lt;/span&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;echo&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;&quot;a&quot;&lt;/span&gt; &lt;=&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;&quot;a&quot;&lt;/span&gt;; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #75715e;&quot;&gt;// 0&lt;/span&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;echo&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;&quot;a&quot;&lt;/span&gt; &lt;=&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;&quot;b&quot;&lt;/span&gt;; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #75715e;&quot;&gt;// -1&lt;/span&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;echo&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;&quot;b&quot;&lt;/span&gt; &lt;=&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;&quot;a&quot;&lt;/span&gt;; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #75715e;&quot;&gt;// 1&lt;/span&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #75715e;&quot;&gt;?&gt;&lt;/span&gt;
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;



&lt;h3 style=&quot;font-family: inherit; font-weight: bold; color: inherit; margin-top: 21px; margin-bottom: 10.5px; font-size: 27.2px; margin: 1.2em 0 .6em 0; text-align: start; line-height: 1.6;&quot;&gt;[7.0] Constant arrays using define()&lt;/h3&gt;



&lt;pre  style=&quot;font-family: 'Source Code Pro',monospace; white-space: pre-wrap; display: block; background-color: rgba(102,128,153,0.05); color: #333; word-wrap: break-word; font-size: .9em; background: #f6f6f6; line-height: 1.6; margin: 0 0 1.1em; padding: 0; border: 0; border-radius: 5px; text-align: start; word-break: break-all;&quot;&gt;&lt;code  style=&quot;font-family: 'Source Code Pro',monospace; font-size: inherit; background-color: transparent; white-space: pre-wrap; border-radius: 0; color: #f8f8f2; display: block; overflow-x: auto; background: #23241f; padding: 1.3em 2em;&quot;&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #75715e;&quot;&gt;&lt;?php&lt;/span&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;define(&lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;'ANIMALS'&lt;/span&gt;, [
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;    &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;'dog'&lt;/span&gt;,
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;    &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;'cat'&lt;/span&gt;,
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;    &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;'bird'&lt;/span&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;]);
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;echo&lt;/span&gt; ANIMALS[&lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;1&lt;/span&gt;]; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #75715e;&quot;&gt;// outputs &quot;cat&quot;&lt;/span&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #75715e;&quot;&gt;?&gt;&lt;/span&gt;
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;



&lt;h3 style=&quot;font-family: inherit; font-weight: bold; color: inherit; margin-top: 21px; margin-bottom: 10.5px; font-size: 27.2px; margin: 1.2em 0 .6em 0; text-align: start; line-height: 1.6;&quot;&gt;[7.0] Anonymous classes&lt;/h3&gt;



&lt;pre  style=&quot;font-family: 'Source Code Pro',monospace; white-space: pre-wrap; display: block; background-color: rgba(102,128,153,0.05); color: #333; word-wrap: break-word; font-size: .9em; background: #f6f6f6; line-height: 1.6; margin: 0 0 1.1em; padding: 0; border: 0; border-radius: 5px; text-align: start; word-break: break-all;&quot;&gt;&lt;code  style=&quot;font-family: 'Source Code Pro',monospace; font-size: inherit; background-color: transparent; white-space: pre-wrap; border-radius: 0; color: #f8f8f2; display: block; overflow-x: auto; background: #23241f; padding: 1.3em 2em;&quot;&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #75715e;&quot;&gt;&lt;?php&lt;/span&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;$app = &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;new&lt;/span&gt; Application;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;$app-&gt;setLogger(&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;new&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #66d9ef;&quot;&gt;class&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;implements&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #a6e22e; font-style: italic;&quot;&gt;Logger&lt;/span&gt; &lt;/span&gt;{
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;    &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;public&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #66d9ef;&quot;&gt;function&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #a6e22e;&quot;&gt;log&lt;/span&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f8f8f2;&quot;&gt;(string $msg)&lt;/span&gt; &lt;/span&gt;{
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;        &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;echo&lt;/span&gt; $msg;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;    }
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;});
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;var_dump($app-&gt;getLogger());
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #75715e;&quot;&gt;?&gt;&lt;/span&gt;
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;



&lt;h3 style=&quot;font-family: inherit; font-weight: bold; color: inherit; margin-top: 21px; margin-bottom: 10.5px; font-size: 27.2px; margin: 1.2em 0 .6em 0; text-align: start; line-height: 1.6;&quot;&gt;[7.0] Unicode codepoint escape syntax&lt;/h3&gt;

&lt;blockquote style=&quot;padding: 15px 20px; margin: 0 0 1.1em; border-left: 5px solid rgba(102,128,153,0.075); border-left-width: 10px; background-color: rgba(102,128,153,0.05); border-top-right-radius: 5px; border-bottom-right-radius: 5px;&quot;&gt;
  &lt;p style=&quot;margin: 0 0 1.1em; font-size: 1em; font-weight: 300; margin-bottom: 0; line-height: 1.6;&quot;&gt;This takes a Unicode codepoint in hexadecimal form, and outputs that codepoint in UTF-8 to a double-quoted string or a heredoc. Any valid codepoint is accepted, with leading 0’s being optional.&lt;/p&gt;
&lt;/blockquote&gt;



&lt;pre  style=&quot;font-family: 'Source Code Pro',monospace; white-space: pre-wrap; display: block; background-color: rgba(102,128,153,0.05); color: #333; word-wrap: break-word; font-size: .9em; background: #f6f6f6; line-height: 1.6; margin: 0 0 1.1em; padding: 0; border: 0; border-radius: 5px; text-align: start; word-break: break-all;&quot;&gt;&lt;code  style=&quot;font-family: 'Source Code Pro',monospace; font-size: inherit; background-color: transparent; white-space: pre-wrap; border-radius: 0; color: #f8f8f2; display: block; overflow-x: auto; background: #23241f; padding: 1.3em 2em;&quot;&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;echo&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;&quot;\u{aa}&quot;&lt;/span&gt;;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;echo&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;&quot;\u{0000aa}&quot;&lt;/span&gt;;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;echo&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;&quot;\u{9999}&quot;&lt;/span&gt;;
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;



&lt;pre  style=&quot;font-family: 'Source Code Pro',monospace; white-space: pre-wrap; display: block; background-color: rgba(102,128,153,0.05); color: #333; word-wrap: break-word; font-size: .9em; background: #f6f6f6; line-height: 1.6; margin: 0 0 1.1em; padding: 0; border: 0; border-radius: 5px; text-align: start; word-break: break-all;&quot;&gt;&lt;code  style=&quot;font-family: 'Source Code Pro',monospace; font-size: inherit; background-color: transparent; white-space: pre-wrap; border-radius: 0; color: #f8f8f2; display: block; overflow-x: auto; background: #23241f; padding: 1.3em 2em;&quot;&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;ª
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;ª (same &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;as&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;before&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;but&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;with&lt;/span&gt; optional leading &lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;0&lt;/span&gt;'s)
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;香
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;



&lt;h3 style=&quot;font-family: inherit; font-weight: bold; color: inherit; margin-top: 21px; margin-bottom: 10.5px; font-size: 27.2px; margin: 1.2em 0 .6em 0; text-align: start; line-height: 1.6;&quot;&gt;[7.0] Closure::call()&lt;/h3&gt;

&lt;p style=&quot;margin: 0 0 1.1em; line-height: 1.6;&quot;&gt;&lt;a href=&quot;http://php.net/manual/fr/closure.call.php&quot; target=&quot;_blank&quot; style=&quot;background: transparent; color: #1980e6; text-decoration: none;&quot;&gt;Closure::call()&lt;/a&gt; is a more performant, shorthand way of temporarily binding an object scope to a closure and invoking it.&lt;/p&gt;



&lt;pre  style=&quot;font-family: 'Source Code Pro',monospace; white-space: pre-wrap; display: block; background-color: rgba(102,128,153,0.05); color: #333; word-wrap: break-word; font-size: .9em; background: #f6f6f6; line-height: 1.6; margin: 0 0 1.1em; padding: 0; border: 0; border-radius: 5px; text-align: start; word-break: break-all;&quot;&gt;&lt;code  style=&quot;font-family: 'Source Code Pro',monospace; font-size: inherit; background-color: transparent; white-space: pre-wrap; border-radius: 0; color: #f8f8f2; display: block; overflow-x: auto; background: #23241f; padding: 1.3em 2em;&quot;&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #75715e;&quot;&gt;&lt;?php&lt;/span&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #66d9ef;&quot;&gt;class&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #a6e22e; font-style: italic;&quot;&gt;A&lt;/span&gt; &lt;/span&gt;{&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;private&lt;/span&gt; $x = &lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;1&lt;/span&gt;;}
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #75715e;&quot;&gt;// Pre PHP 7 code&lt;/span&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;$getXCB = &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #66d9ef;&quot;&gt;function&lt;/span&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f8f8f2;&quot;&gt;()&lt;/span&gt; &lt;/span&gt;{&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;return&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;$this&lt;/span&gt;-&gt;x;};
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;$getX = $getXCB-&gt;bindTo(&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;new&lt;/span&gt; A, &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;'A'&lt;/span&gt;); &lt;span  style=&quot;display: inline; line-height: 1.6; color: #75715e;&quot;&gt;// intermediate closure&lt;/span&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;echo&lt;/span&gt; $getX();
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #75715e;&quot;&gt;// PHP 7+ code&lt;/span&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;$getX = &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #66d9ef;&quot;&gt;function&lt;/span&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f8f8f2;&quot;&gt;()&lt;/span&gt; &lt;/span&gt;{&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;return&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;$this&lt;/span&gt;-&gt;x;};
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;echo&lt;/span&gt; $getX-&gt;call(&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;new&lt;/span&gt; A);
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;



&lt;h3 style=&quot;font-family: inherit; font-weight: bold; color: inherit; margin-top: 21px; margin-bottom: 10.5px; font-size: 27.2px; margin: 1.2em 0 .6em 0; text-align: start; line-height: 1.6;&quot;&gt;[7.0] Filtered unserialize()&lt;/h3&gt;

&lt;blockquote style=&quot;padding: 15px 20px; margin: 0 0 1.1em; border-left: 5px solid rgba(102,128,153,0.075); border-left-width: 10px; background-color: rgba(102,128,153,0.05); border-top-right-radius: 5px; border-bottom-right-radius: 5px;&quot;&gt;
  &lt;p style=&quot;margin: 0 0 1.1em; font-size: 1em; font-weight: 300; margin-bottom: 0; line-height: 1.6;&quot;&gt;This feature seeks to provide better security when unserializing objects on untrusted data. It prevents possible code injections by enabling the developer to whitelist classes that can be unserialized. &lt;/p&gt;
&lt;/blockquote&gt;



&lt;pre  style=&quot;font-family: 'Source Code Pro',monospace; white-space: pre-wrap; display: block; background-color: rgba(102,128,153,0.05); color: #333; word-wrap: break-word; font-size: .9em; background: #f6f6f6; line-height: 1.6; margin: 0 0 1.1em; padding: 0; border: 0; border-radius: 5px; text-align: start; word-break: break-all;&quot;&gt;&lt;code  style=&quot;font-family: 'Source Code Pro',monospace; font-size: inherit; background-color: transparent; white-space: pre-wrap; border-radius: 0; color: #f8f8f2; display: block; overflow-x: auto; background: #23241f; padding: 1.3em 2em;&quot;&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #75715e;&quot;&gt;// converts all objects into __PHP_Incomplete_Class object&lt;/span&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;$data = unserialize($foo, [&lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;&quot;allowed_classes&quot;&lt;/span&gt; =&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;false&lt;/span&gt;]);
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #75715e;&quot;&gt;// converts all objects into __PHP_Incomplete_Class object except those of MyClass and MyClass2&lt;/span&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;$data = unserialize($foo, [&lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;&quot;allowed_classes&quot;&lt;/span&gt; =&gt; [&lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;&quot;MyClass&quot;&lt;/span&gt;, &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;&quot;MyClass2&quot;&lt;/span&gt;]]);
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #75715e;&quot;&gt;// default behaviour (same as omitting the second argument) that accepts all classes&lt;/span&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;$data = unserialize($foo, [&lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;&quot;allowed_classes&quot;&lt;/span&gt; =&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;true&lt;/span&gt;]);
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;



&lt;h3 style=&quot;font-family: inherit; font-weight: bold; color: inherit; margin-top: 21px; margin-bottom: 10.5px; font-size: 27.2px; margin: 1.2em 0 .6em 0; text-align: start; line-height: 1.6;&quot;&gt;[7.0] Group use declarations&lt;/h3&gt;



&lt;pre  style=&quot;font-family: 'Source Code Pro',monospace; white-space: pre-wrap; display: block; background-color: rgba(102,128,153,0.05); color: #333; word-wrap: break-word; font-size: .9em; background: #f6f6f6; line-height: 1.6; margin: 0 0 1.1em; padding: 0; border: 0; border-radius: 5px; text-align: start; word-break: break-all;&quot;&gt;&lt;code  style=&quot;font-family: 'Source Code Pro',monospace; font-size: inherit; background-color: transparent; white-space: pre-wrap; border-radius: 0; color: #f8f8f2; display: block; overflow-x: auto; background: #23241f; padding: 1.3em 2em;&quot;&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;use&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #a6e22e;&quot;&gt;some&lt;/span&gt;\&lt;span  style=&quot;display: inline; line-height: 1.6; color: #a6e22e;&quot;&gt;namespace&lt;/span&gt;\{&lt;span  style=&quot;display: inline; line-height: 1.6; color: #a6e22e;&quot;&gt;ClassA&lt;/span&gt;, &lt;span  style=&quot;display: inline; line-height: 1.6; color: #a6e22e;&quot;&gt;ClassB&lt;/span&gt;, &lt;span  style=&quot;display: inline; line-height: 1.6; color: #a6e22e;&quot;&gt;ClassC&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #a6e22e;&quot;&gt;as&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #a6e22e;&quot;&gt;C&lt;/span&gt;};
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;use&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #a6e22e;&quot;&gt;function&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #a6e22e;&quot;&gt;some&lt;/span&gt;\&lt;span  style=&quot;display: inline; line-height: 1.6; color: #a6e22e;&quot;&gt;namespace&lt;/span&gt;\{&lt;span  style=&quot;display: inline; line-height: 1.6; color: #a6e22e;&quot;&gt;fn_a&lt;/span&gt;, &lt;span  style=&quot;display: inline; line-height: 1.6; color: #a6e22e;&quot;&gt;fn_b&lt;/span&gt;, &lt;span  style=&quot;display: inline; line-height: 1.6; color: #a6e22e;&quot;&gt;fn_c&lt;/span&gt;};
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;use&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #a6e22e;&quot;&gt;const&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #a6e22e;&quot;&gt;some&lt;/span&gt;\&lt;span  style=&quot;display: inline; line-height: 1.6; color: #a6e22e;&quot;&gt;namespace&lt;/span&gt;\{&lt;span  style=&quot;display: inline; line-height: 1.6; color: #a6e22e;&quot;&gt;ConstA&lt;/span&gt;, &lt;span  style=&quot;display: inline; line-height: 1.6; color: #a6e22e;&quot;&gt;ConstB&lt;/span&gt;, &lt;span  style=&quot;display: inline; line-height: 1.6; color: #a6e22e;&quot;&gt;ConstC&lt;/span&gt;};
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;



&lt;h3 style=&quot;font-family: inherit; font-weight: bold; color: inherit; margin-top: 21px; margin-bottom: 10.5px; font-size: 27.2px; margin: 1.2em 0 .6em 0; text-align: start; line-height: 1.6;&quot;&gt;[7.0] list() can always unpack objects implementing ArrayAccess&lt;/h3&gt;

&lt;blockquote style=&quot;padding: 15px 20px; margin: 0 0 1.1em; border-left: 5px solid rgba(102,128,153,0.075); border-left-width: 10px; background-color: rgba(102,128,153,0.05); border-top-right-radius: 5px; border-bottom-right-radius: 5px;&quot;&gt;
  &lt;p style=&quot;margin: 0 0 1.1em; font-size: 1em; font-weight: 300; margin-bottom: 0; line-height: 1.6;&quot;&gt;Previously, list() was not guaranteed to operate correctly with objects implementing ArrayAccess. This has been fixed.&lt;/p&gt;
&lt;/blockquote&gt;



&lt;h3 style=&quot;font-family: inherit; font-weight: bold; color: inherit; margin-top: 21px; margin-bottom: 10.5px; font-size: 27.2px; margin: 1.2em 0 .6em 0; text-align: start; line-height: 1.6;&quot;&gt;[7.0] preg_replace_callback_array()&lt;/h3&gt;

&lt;blockquote style=&quot;padding: 15px 20px; margin: 0 0 1.1em; border-left: 5px solid rgba(102,128,153,0.075); border-left-width: 10px; background-color: rgba(102,128,153,0.05); border-top-right-radius: 5px; border-bottom-right-radius: 5px;&quot;&gt;
  &lt;p style=&quot;margin: 0 0 1.1em; font-size: 1em; font-weight: 300; margin-bottom: 0; line-height: 1.6;&quot;&gt;The new &lt;a href=&quot;http://php.net/manual/fr/function.preg-replace-callback-array.php&quot; target=&quot;_blank&quot; style=&quot;background: transparent; color: #1980e6; text-decoration: none;&quot;&gt;preg_replace_callback_array()&lt;/a&gt; function enables code to be written more cleanly when using the preg_replace_callback() function. Prior to PHP 7, callbacks that needed to be executed per regular expression required the callback function to be polluted with lots of branching.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p style=&quot;margin: 0 0 1.1em; line-height: 1.6;&quot;&gt;Now, callbacks can be registered to each regular expression using an associative array, where the key is a regular expression and the value is a callback.&lt;/p&gt;



&lt;h3 style=&quot;font-family: inherit; font-weight: bold; color: inherit; margin-top: 21px; margin-bottom: 10.5px; font-size: 27.2px; margin: 1.2em 0 .6em 0; text-align: start; line-height: 1.6;&quot;&gt;[7.0] Integer division with intdiv()&lt;/h3&gt;

&lt;blockquote style=&quot;padding: 15px 20px; margin: 0 0 1.1em; border-left: 5px solid rgba(102,128,153,0.075); border-left-width: 10px; background-color: rgba(102,128,153,0.05); border-top-right-radius: 5px; border-bottom-right-radius: 5px;&quot;&gt;
  &lt;p style=&quot;margin: 0 0 1.1em; font-size: 1em; font-weight: 300; margin-bottom: 0; line-height: 1.6;&quot;&gt;The new &lt;a href=&quot;http://php.net/manual/fr/function.intdiv.php&quot; target=&quot;_blank&quot; style=&quot;background: transparent; color: #1980e6; text-decoration: none;&quot;&gt;intdiv()&lt;/a&gt; function performs an integer division of its operands and returns it.&lt;/p&gt;
&lt;/blockquote&gt;



&lt;pre  style=&quot;font-family: 'Source Code Pro',monospace; white-space: pre-wrap; display: block; background-color: rgba(102,128,153,0.05); color: #333; word-wrap: break-word; font-size: .9em; background: #f6f6f6; line-height: 1.6; margin: 0 0 1.1em; padding: 0; border: 0; border-radius: 5px; text-align: start; word-break: break-all;&quot;&gt;&lt;code  style=&quot;font-family: 'Source Code Pro',monospace; font-size: inherit; background-color: transparent; white-space: pre-wrap; border-radius: 0; color: #f8f8f2; display: block; overflow-x: auto; background: #23241f; padding: 1.3em 2em;&quot;&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;var_dump(intdiv(&lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;3&lt;/span&gt;, &lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;2&lt;/span&gt;));
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;var_dump(&lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;3&lt;/span&gt;/&lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;2&lt;/span&gt;);
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;



&lt;pre  style=&quot;font-family: 'Source Code Pro',monospace; white-space: pre-wrap; display: block; background-color: rgba(102,128,153,0.05); color: #333; word-wrap: break-word; font-size: .9em; background: #f6f6f6; line-height: 1.6; margin: 0 0 1.1em; padding: 0; border: 0; border-radius: 5px; text-align: start; word-break: break-all;&quot;&gt;&lt;code  style=&quot;font-family: 'Source Code Pro',monospace; font-size: inherit; background-color: transparent; white-space: pre-wrap; border-radius: 0; color: #f8f8f2; display: block; overflow-x: auto; background: #23241f; padding: 1.3em 2em;&quot;&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #a6e22e;&quot;&gt;int&lt;/span&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f8f8f2;&quot;&gt;(&lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;1&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #a6e22e;&quot;&gt;float&lt;/span&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f8f8f2;&quot;&gt;(&lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;1.5&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;



&lt;h2 style=&quot;font-family: inherit; font-weight: bold; line-height: 1.1; color: inherit; margin-top: 21px; margin-bottom: 10.5px; font-size: 34.4px; margin: 1.2em 0 .6em 0; text-align: start;&quot;&gt;PHP Major migration&lt;/h2&gt;

&lt;table style=&quot;border-collapse: collapse; border-spacing: 0; margin-bottom: 20px; line-height: 1.6;&quot;&gt;
&lt;thead style=&quot;line-height: 1.6;&quot;&gt;
&lt;tr style=&quot;line-height: 1.6;&quot;&gt;
  &lt;th align=&quot;left&quot; style=&quot;font-weight: bold; vertical-align: bottom; padding: .5em; border-top: 0; border: 1px solid #ddd; line-height: 1.6;&quot;&gt;Version&lt;/th&gt;
  &lt;th align=&quot;right&quot; style=&quot;font-weight: bold; vertical-align: bottom; padding: .5em; border-top: 0; border: 1px solid #ddd; line-height: 1.6; text-align: right;&quot;/&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody style=&quot;line-height: 1.6;&quot;&gt;&lt;tr style=&quot;line-height: 1.6;&quot;&gt;
  &lt;td align=&quot;left&quot; style=&quot;padding: .5em; vertical-align: top; border-top: 1px solid #ddd; border: 1px solid #ddd; line-height: 1.6;&quot;&gt;7.0 -&gt; 7.1&lt;/td&gt;
  &lt;td align=&quot;right&quot; style=&quot;padding: .5em; vertical-align: top; border-top: 1px solid #ddd; border: 1px solid #ddd; line-height: 1.6;&quot;&gt;&lt;a href=&quot;http://php.net/manual/fr/migration71.php&quot; target=&quot;_blank&quot; style=&quot;background: transparent; color: #1980e6; text-decoration: none;&quot;&gt;http://php.net/manual/fr/migration71.php&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style=&quot;line-height: 1.6;&quot;&gt;
  &lt;td align=&quot;left&quot; style=&quot;padding: .5em; vertical-align: top; border-top: 1px solid #ddd; border: 1px solid #ddd; line-height: 1.6;&quot;&gt;5.6 -&gt; 7.0&lt;/td&gt;
  &lt;td align=&quot;right&quot; style=&quot;padding: .5em; vertical-align: top; border-top: 1px solid #ddd; border: 1px solid #ddd; line-height: 1.6;&quot;&gt;&lt;a href=&quot;http://php.net/manual/fr/migration70.php&quot; target=&quot;_blank&quot; style=&quot;background: transparent; color: #1980e6; text-decoration: none;&quot;&gt;http://php.net/manual/fr/migration70.php&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style=&quot;line-height: 1.6;&quot;&gt;
  &lt;td align=&quot;left&quot; style=&quot;padding: .5em; vertical-align: top; border-top: 1px solid #ddd; border: 1px solid #ddd; line-height: 1.6;&quot;&gt;5.5 -&gt; 5.6&lt;/td&gt;
  &lt;td align=&quot;right&quot; style=&quot;padding: .5em; vertical-align: top; border-top: 1px solid #ddd; border: 1px solid #ddd; line-height: 1.6;&quot;&gt;&lt;a href=&quot;http://php.net/manual/fr/migration56.php&quot; target=&quot;_blank&quot; style=&quot;background: transparent; color: #1980e6; text-decoration: none;&quot;&gt;http://php.net/manual/fr/migration56.php&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;




&lt;h2 style=&quot;font-family: inherit; font-weight: bold; line-height: 1.1; color: inherit; margin-top: 21px; margin-bottom: 10.5px; font-size: 34.4px; margin: 1.2em 0 .6em 0; text-align: start;&quot;&gt;Tips (There are micro optimizations)&lt;/h2&gt;



&lt;h3 style=&quot;font-family: inherit; font-weight: bold; color: inherit; margin-top: 21px; margin-bottom: 10.5px; font-size: 27.2px; margin: 1.2em 0 .6em 0; text-align: start; line-height: 1.6;&quot;&gt;[7] Packed arrays&lt;/h3&gt;

&lt;blockquote style=&quot;padding: 15px 20px; margin: 0 0 1.1em; border-left: 5px solid rgba(102,128,153,0.075); border-left-width: 10px; background-color: rgba(102,128,153,0.05); border-top-right-radius: 5px; border-bottom-right-radius: 5px;&quot;&gt;
  &lt;p style=&quot;margin: 0 0 1.1em; font-size: 1em; font-weight: 300; margin-bottom: 1.1em; line-height: 1.6;&quot;&gt;Packed arrays is the first great PHP 7 optimization. Packed arrays consume less memory and are a bit faster in many operations than traditional arrays. A packed array must have the following characteristics:&lt;/p&gt;
  
  &lt;ul style=&quot;margin-top: 0; margin-bottom: 0; line-height: 1.6;&quot;&gt;&lt;li style=&quot;line-height: 1.6;&quot;&gt;The keys are only integers;&lt;/li&gt;
  &lt;li style=&quot;line-height: 1.6;&quot;&gt;The keys are inserted into the array in growing only mode.&lt;/li&gt;
  &lt;/ul&gt;
&lt;/blockquote&gt;



&lt;pre  style=&quot;font-family: 'Source Code Pro',monospace; white-space: pre-wrap; display: block; background-color: rgba(102,128,153,0.05); color: #333; word-wrap: break-word; font-size: .9em; background: #f6f6f6; line-height: 1.6; margin: 0 0 1.1em; padding: 0; border: 0; border-radius: 5px; text-align: start; word-break: break-all;&quot;&gt;&lt;code  style=&quot;font-family: 'Source Code Pro',monospace; font-size: inherit; background-color: transparent; white-space: pre-wrap; border-radius: 0; color: #f8f8f2; display: block; overflow-x: auto; background: #23241f; padding: 1.3em 2em;&quot;&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;$a = [&lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;'foo'&lt;/span&gt;, &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;'bar'&lt;/span&gt;, &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;'baz'&lt;/span&gt;];
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;$a = [&lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;12&lt;/span&gt; =&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;'baz'&lt;/span&gt;, &lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;42&lt;/span&gt; =&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;'bar'&lt;/span&gt;, &lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;67&lt;/span&gt; =&gt; [] ];
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;blockquote style=&quot;padding: 15px 20px; margin: 0 0 1.1em; border-left: 5px solid rgba(102,128,153,0.075); border-left-width: 10px; background-color: rgba(102,128,153,0.05); border-top-right-radius: 5px; border-bottom-right-radius: 5px;&quot;&gt;
  &lt;p style=&quot;margin: 0 0 1.1em; font-size: 1em; font-weight: 300; margin-bottom: 0; line-height: 1.6;&quot;&gt;&lt;strong style=&quot;font-weight: bold; line-height: 1.6;&quot;&gt;TIPS&lt;/strong&gt;  &lt;code style=&quot;font-family: 'Source Code Pro',monospace; font-size: .9em; padding: 2px 4px; color: #c7254e; background-color: #f9f2f4; white-space: normal; border-radius: 4px;&quot;&gt;$pdo-&gt;query(&quot;SELECT * FROM table LIMIT 10000&quot;)-&gt;fetchAll(PDO::FETCH_NUM)&lt;/code&gt; &lt;/p&gt;
&lt;/blockquote&gt;



&lt;h3 style=&quot;font-family: inherit; font-weight: bold; color: inherit; margin-top: 21px; margin-bottom: 10.5px; font-size: 27.2px; margin: 1.2em 0 .6em 0; text-align: start; line-height: 1.6;&quot;&gt;[7] ints/floats are free&lt;/h3&gt;

&lt;blockquote style=&quot;padding: 15px 20px; margin: 0 0 1.1em; border-left: 5px solid rgba(102,128,153,0.075); border-left-width: 10px; background-color: rgba(102,128,153,0.05); border-top-right-radius: 5px; border-bottom-right-radius: 5px;&quot;&gt;
  &lt;p style=&quot;margin: 0 0 1.1em; font-size: 1em; font-weight: 300; margin-bottom: 0; line-height: 1.6;&quot;&gt;In PHP 7, the way variables are allocated in memory changed dramatically. They went from being stored on the heap to stack memory pools. As a side effect, you may reuse variable containers for free: no memory allocated. That’s impossible to do in PHP 5, where each variable creation/assignment requires some memory allocation (which is bad for performance).&lt;/p&gt;
&lt;/blockquote&gt;



&lt;pre  style=&quot;font-family: 'Source Code Pro',monospace; white-space: pre-wrap; display: block; background-color: rgba(102,128,153,0.05); color: #333; word-wrap: break-word; font-size: .9em; background: #f6f6f6; line-height: 1.6; margin: 0 0 1.1em; padding: 0; border: 0; border-radius: 5px; text-align: start; word-break: break-all;&quot;&gt;&lt;code  style=&quot;font-family: 'Source Code Pro',monospace; font-size: inherit; background-color: transparent; white-space: pre-wrap; border-radius: 0; color: #f8f8f2; display: block; overflow-x: auto; background: #23241f; padding: 1.3em 2em;&quot;&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;for&lt;/span&gt; ($i=&lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;0&lt;/span&gt;; $i&lt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;10000&lt;/span&gt;; $i++) {
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;    $$i = &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;'foo'&lt;/span&gt;;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;}
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;p style=&quot;margin: 0 0 1.1em; line-height: 1.6;&quot;&gt;&lt;strong style=&quot;font-weight: bold; line-height: 1.6;&quot;&gt;VS&lt;/strong&gt;&lt;/p&gt;



&lt;pre  style=&quot;font-family: 'Source Code Pro',monospace; white-space: pre-wrap; display: block; background-color: rgba(102,128,153,0.05); color: #333; word-wrap: break-word; font-size: .9em; background: #f6f6f6; line-height: 1.6; margin: 0 0 1.1em; padding: 0; border: 0; border-radius: 5px; text-align: start; word-break: break-all;&quot;&gt;&lt;code  style=&quot;font-family: 'Source Code Pro',monospace; font-size: inherit; background-color: transparent; white-space: pre-wrap; border-radius: 0; color: #f8f8f2; display: block; overflow-x: auto; background: #23241f; padding: 1.3em 2em;&quot;&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;for&lt;/span&gt; ($i=&lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;0&lt;/span&gt;; $i&lt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;10000&lt;/span&gt;; $i++) {
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;    $$i = &lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;42&lt;/span&gt;;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;}
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;



&lt;p style=&quot;margin: 0 0 1.1em; line-height: 1.6;&quot;&gt;&lt;img src=&quot;https://cdn-images.postach.io/0ae34934-1fa7-4ba9-8006-c5903a09de37/daf606d0-af9d-4c40-b4b4-837e96f9dcfd/8800e933-d03a-4b1e-bfc5-cc12fd6c898f.png&quot;  longdesc=&quot;./variable-integer.png&quot; alt=&quot;Alt text&quot; style=&quot;border: 0; vertical-align: middle; max-width: 100%;&quot;/&gt;&lt;/p&gt;



&lt;h3 style=&quot;font-family: inherit; font-weight: bold; color: inherit; margin-top: 21px; margin-bottom: 10.5px; font-size: 27.2px; margin: 1.2em 0 .6em 0; text-align: start; line-height: 1.6;&quot;&gt;[7] References mismatch&lt;/h3&gt;

&lt;p style=&quot;margin: 0 0 1.1em; line-height: 1.6;&quot;&gt;Reference mismatch happens when you pass a non-ref variable to a function argument passed-by-ref, or the opposite. Something like this:&lt;/p&gt;



&lt;pre  style=&quot;font-family: 'Source Code Pro',monospace; white-space: pre-wrap; display: block; background-color: rgba(102,128,153,0.05); color: #333; word-wrap: break-word; font-size: .9em; background: #f6f6f6; line-height: 1.6; margin: 0 0 1.1em; padding: 0; border: 0; border-radius: 5px; text-align: start; word-break: break-all;&quot;&gt;&lt;code  style=&quot;font-family: 'Source Code Pro',monospace; font-size: inherit; background-color: transparent; white-space: pre-wrap; border-radius: 0; color: #f8f8f2; display: block; overflow-x: auto; background: #23241f; padding: 1.3em 2em;&quot;&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #66d9ef;&quot;&gt;function&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #a6e22e;&quot;&gt;foo&lt;/span&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f8f8f2;&quot;&gt;(&amp;$arg)&lt;/span&gt; &lt;/span&gt;{ }
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;$var = &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;'str'&lt;/span&gt;;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;foo($var);
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;p style=&quot;margin: 0 0 1.1em; line-height: 1.6;&quot;&gt;Do you know what horrible things happen under the hood in the PHP 5 engine? In PHP 5, whenever there is a reference mismatch, the engine is forced to duplicate the variable before passing it as an argument to a function. As you probably guessed, if the variable contains something big, like a several-thousands-entries array or a big chunk of string; the copy will take a lot of time.&lt;/p&gt;

&lt;p style=&quot;margin: 0 0 1.1em; line-height: 1.6;&quot;&gt;This is because of the way variables and references used to work into PHP 5. When going into the body function, the engine doesn’t know yet if you will change the argument value. If you are, then as the argument is taken by reference, the change must be reflected outside if a reference variable were passed. What if it was not the case (as in our example)? The engine must then create a reference, from the non-reference variable you passed it in the function call. This procedure leads the engine to fully duplicate the variable content in PHP 5 (calling a lot of memcpy() on very sparse pointers, leading to tons of slow memory accesses).&lt;/p&gt;

&lt;p style=&quot;margin: 0 0 1.1em; line-height: 1.6;&quot;&gt;In PHP 7, when the engine wants to create a reference from a non-reference variable, it just wraps the latter into the newly created former, that’s all. There is no memory copy, anywhere. This is because variables work in a very different way internally in PHP 7, and references have been deeply reworked.&lt;/p&gt;

&lt;p style=&quot;margin: 0 0 1.1em; line-height: 1.6;&quot;&gt;Look at this piece of code:&lt;/p&gt;



&lt;pre  style=&quot;font-family: 'Source Code Pro',monospace; white-space: pre-wrap; display: block; background-color: rgba(102,128,153,0.05); color: #333; word-wrap: break-word; font-size: .9em; background: #f6f6f6; line-height: 1.6; margin: 0 0 1.1em; padding: 0; border: 0; border-radius: 5px; text-align: start; word-break: break-all;&quot;&gt;&lt;code  style=&quot;font-family: 'Source Code Pro',monospace; font-size: inherit; background-color: transparent; white-space: pre-wrap; border-radius: 0; color: #f8f8f2; display: block; overflow-x: auto; background: #23241f; padding: 1.3em 2em;&quot;&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #66d9ef;&quot;&gt;function&lt;/span&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #a6e22e;&quot;&gt;bar&lt;/span&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f8f8f2;&quot;&gt;(&amp;$a)&lt;/span&gt; &lt;/span&gt;{ $f = $a; }
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;$var = range(&lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;1&lt;/span&gt;,&lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;1024&lt;/span&gt;);
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;for&lt;/span&gt; ($i=&lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;0&lt;/span&gt;; $i&lt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;1000&lt;/span&gt;; $i++) {
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;bar($var);
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;}
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;p style=&quot;margin: 0 0 1.1em; line-height: 1.6;&quot;&gt;There is a double mismatch. When you call bar(), you force the engine to create a reference from &lt;code style=&quot;font-family: 'Source Code Pro',monospace; font-size: .9em; padding: 2px 4px; color: #c7254e; background-color: #f9f2f4; white-space: normal; border-radius: 4px;&quot;&gt;$var&lt;/code&gt;  to &lt;code style=&quot;font-family: 'Source Code Pro',monospace; font-size: .9em; padding: 2px 4px; color: #c7254e; background-color: #f9f2f4; white-space: normal; border-radius: 4px;&quot;&gt;$a&lt;/code&gt; , as the signature says &lt;code style=&quot;font-family: 'Source Code Pro',monospace; font-size: .9em; padding: 2px 4px; color: #c7254e; background-color: #f9f2f4; white-space: normal; border-radius: 4px;&quot;&gt;&amp;$a&lt;/code&gt;. Then, now that &lt;code style=&quot;font-family: 'Source Code Pro',monospace; font-size: .9em; padding: 2px 4px; color: #c7254e; background-color: #f9f2f4; white-space: normal; border-radius: 4px;&quot;&gt;$a&lt;/code&gt; is part of a reference set (&lt;code style=&quot;font-family: 'Source Code Pro',monospace; font-size: .9em; padding: 2px 4px; color: #c7254e; background-color: #f9f2f4; white-space: normal; border-radius: 4px;&quot;&gt;$var-$a&lt;/code&gt;) into the bar() body, you affect it by value to &lt;code style=&quot;font-family: 'Source Code Pro',monospace; font-size: .9em; padding: 2px 4px; color: #c7254e; background-color: #f9f2f4; white-space: normal; border-radius: 4px;&quot;&gt;$f&lt;/code&gt;: this is another mismatch. &lt;code style=&quot;font-family: 'Source Code Pro',monospace; font-size: .9em; padding: 2px 4px; color: #c7254e; background-color: #f9f2f4; white-space: normal; border-radius: 4px;&quot;&gt;$f&lt;/code&gt; is not affected by reference, so &lt;code style=&quot;font-family: 'Source Code Pro',monospace; font-size: .9em; padding: 2px 4px; color: #c7254e; background-color: #f9f2f4; white-space: normal; border-radius: 4px;&quot;&gt;$a-$f-$var&lt;/code&gt; must not be linked together, but &lt;code style=&quot;font-family: 'Source Code Pro',monospace; font-size: .9em; padding: 2px 4px; color: #c7254e; background-color: #f9f2f4; white-space: normal; border-radius: 4px;&quot;&gt;$var-$a&lt;/code&gt; in one part, and &lt;code style=&quot;font-family: 'Source Code Pro',monospace; font-size: .9em; padding: 2px 4px; color: #c7254e; background-color: #f9f2f4; white-space: normal; border-radius: 4px;&quot;&gt;$f&lt;/code&gt; alone in another part: you once more force the engine to perform some copies. In PHP 7, creating variables to/from references is pretty light, only copy-on-write may happen after that.&lt;/p&gt;



&lt;p style=&quot;margin: 0 0 1.1em; line-height: 1.6;&quot;&gt;&lt;img src=&quot;https://cdn-images.postach.io/0ae34934-1fa7-4ba9-8006-c5903a09de37/daf606d0-af9d-4c40-b4b4-837e96f9dcfd/ffbaaf6f-fc76-49ee-9bba-7169567a9422.png&quot;  longdesc=&quot;./ref-mis.png&quot; alt=&quot;Alt text&quot; style=&quot;border: 0; vertical-align: middle; max-width: 100%;&quot;/&gt;&lt;/p&gt;



&lt;h3 style=&quot;font-family: inherit; font-weight: bold; color: inherit; margin-top: 21px; margin-bottom: 10.5px; font-size: 27.2px; margin: 1.2em 0 .6em 0; text-align: start; line-height: 1.6;&quot;&gt;[7] Immutable arrays&lt;/h3&gt;

&lt;p style=&quot;margin: 0 0 1.1em; line-height: 1.6;&quot;&gt;Immutable arrays are a concept added to PHP 7, and part of the OPCache extension, which I assume you are using. An immutable array is an array full of immutable elements, which are compile-time known and fully resolved values: strings, integers, floats, or arrays containing those. In a word: no dynamic elements, no variables, like in this example:&lt;/p&gt;



&lt;pre  style=&quot;font-family: 'Source Code Pro',monospace; white-space: pre-wrap; display: block; background-color: rgba(102,128,153,0.05); color: #333; word-wrap: break-word; font-size: .9em; background: #f6f6f6; line-height: 1.6; margin: 0 0 1.1em; padding: 0; border: 0; border-radius: 5px; text-align: start; word-break: break-all;&quot;&gt;&lt;code  style=&quot;font-family: 'Source Code Pro',monospace; font-size: inherit; background-color: transparent; white-space: pre-wrap; border-radius: 0; color: #f8f8f2; display: block; overflow-x: auto; background: #23241f; padding: 1.3em 2em;&quot;&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;$ar = [ &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;'foo'&lt;/span&gt;, &lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;42&lt;/span&gt;, &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;'bar'&lt;/span&gt;, [&lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;1&lt;/span&gt;, &lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;2&lt;/span&gt;, &lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;3&lt;/span&gt;], &lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;9.87&lt;/span&gt; ];
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;p style=&quot;margin: 0 0 1.1em; line-height: 1.6;&quot;&gt;Such arrays have been optimized in PHP 7. Under PHP 5, those are just plain arrays, there is no difference between an array containing dynamic members (such as &lt;code style=&quot;font-family: 'Source Code Pro',monospace; font-size: .9em; padding: 2px 4px; color: #c7254e; background-color: #f9f2f4; white-space: normal; border-radius: 4px;&quot;&gt;$vars&lt;/code&gt;), and a static compile-time resolved array. In PHP 7, immutable arrays are not copied nor duplicated as soon as they stay read only.&lt;/p&gt;

&lt;p style=&quot;margin: 0 0 1.1em; line-height: 1.6;&quot;&gt;Here is such an example:&lt;/p&gt;



&lt;pre  style=&quot;font-family: 'Source Code Pro',monospace; white-space: pre-wrap; display: block; background-color: rgba(102,128,153,0.05); color: #333; word-wrap: break-word; font-size: .9em; background: #f6f6f6; line-height: 1.6; margin: 0 0 1.1em; padding: 0; border: 0; border-radius: 5px; text-align: start; word-break: break-all;&quot;&gt;&lt;code  style=&quot;font-family: 'Source Code Pro',monospace; font-size: inherit; background-color: transparent; white-space: pre-wrap; border-radius: 0; color: #f8f8f2; display: block; overflow-x: auto; background: #23241f; padding: 1.3em 2em;&quot;&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;&lt;span  style=&quot;display: inline; line-height: 1.6; color: #f92672;&quot;&gt;for&lt;/span&gt; ($i = &lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;0&lt;/span&gt;; $i &lt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;1000&lt;/span&gt;; $i++) {
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;$var[] = [
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;  &lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;0&lt;/span&gt; =&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;'Symfony\\Bundle\\FrameworkBundle\\EventListener\\SessionListener'&lt;/span&gt;,
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;  &lt;span  style=&quot;display: inline; line-height: 1.6; color: #ae81ff;&quot;&gt;1&lt;/span&gt; =&gt; &lt;span  style=&quot;display: inline; line-height: 1.6; color: #e6db74;&quot;&gt;'Symfony\\Component\\HttpFoundation\\Session\\Storage\\NativeSessionStorage'&lt;/span&gt;,
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;  &lt;span  style=&quot;display: inline; line-height: 1.6; color: #75715e;&quot;&gt;/* ... go to many immutable items here */&lt;/span&gt;
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;  ];
&lt;/div&gt;&lt;div  style=&quot;line-height: 1.6;&quot;&gt;}
&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;p style=&quot;margin: 0 0 1.1em; line-height: 1.6;&quot;&gt;The above code creates the same big array 1,000 times (truncated, think of it as being a hundred or thousand slots array).&lt;/p&gt;

&lt;p style=&quot;margin: 0 0 1.1em; line-height: 1.6;&quot;&gt;In PHP 5, this array is duplicated in memory 1,000 times. A big array could weight at several hundreds of Kilobytes or even Megabytes, which in this code will be duplicated 1,000 times. Such a waste of memory.&lt;/p&gt;

&lt;p style=&quot;margin: 0 0 1.1em; line-height: 1.6;&quot;&gt;In PHP 7, OPCache flags those arrays as being immutable: the array is created only once, and shares its memory pointer everywhere it is supposed to be used, ending in huge savings of overall memory, especially when dealing with big configuration arrays, like the one shown in the example (which is taken from the Symfony 3 framework).&lt;/p&gt;

&lt;p style=&quot;margin: 0 0 1.1em; line-height: 1.6;&quot;&gt;Let’s see the performance impact:&lt;/p&gt;

&lt;p style=&quot;margin: 0 0 1.1em; line-height: 1.6;&quot;&gt;&lt;img src=&quot;https://cdn-images.postach.io/0ae34934-1fa7-4ba9-8006-c5903a09de37/daf606d0-af9d-4c40-b4b4-837e96f9dcfd/00c7a5ef-1947-4eed-85de-cf2df5550720.png&quot;  longdesc=&quot;./immutable-arrays.png&quot; alt=&quot;Alt text&quot; style=&quot;border: 0; vertical-align: middle; max-width: 100%;&quot;/&gt;&lt;/p&gt;

&lt;blockquote style=&quot;padding: 15px 20px; margin: 0 0 1.1em; border-left: 5px solid rgba(102,128,153,0.075); border-left-width: 10px; background-color: rgba(102,128,153,0.05); border-top-right-radius: 5px; border-bottom-right-radius: 5px;&quot;&gt;
  &lt;p style=&quot;margin: 0 0 1.1em; font-size: 1em; font-weight: 300; margin-bottom: 0; line-height: 1.6;&quot;&gt;Illustrated example with composer : &lt;a href=&quot;https://github.com/composer/composer/pull/5174&quot; target=&quot;_blank&quot; style=&quot;background: transparent; color: #1980e6; text-decoration: none;&quot;&gt;https://github.com/composer/composer/pull/5174&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p style=&quot;margin: 0 0 1.1em; line-height: 1.6;&quot;&gt;&lt;img src=&quot;https://cdn-images.postach.io/0ae34934-1fa7-4ba9-8006-c5903a09de37/daf606d0-af9d-4c40-b4b4-837e96f9dcfd/b2e1cc71-7ed9-4cf2-bfe4-bd837aeb8a6e.png&quot;  longdesc=&quot;./Screenshot Thu Dec 22 2016 11:34:35 GMT+0100 CET 1517x1036.png&quot; alt=&quot;Alt text&quot; style=&quot;border: 0; vertical-align: middle; max-width: 100%;&quot;/&gt;&lt;/p&gt;&lt;/div&gt;&lt;center style='display:none'&gt;%0A%23%20PHP7%2C%20Stay%20up%20to%20date%20%21%0A%0A@%28Postach.io%29%5Bfeatures%2C%20tips%2C%20performance%2C%20published%2C%20php%5D%0A%0A----------%0A%0A%3E%20TL%3BDR%20Full%20changelog%20http%3A//php.net/ChangeLog-7.php%0A%0A%23%23%20New%20features%0A%0A%23%23%23%20%5B7.1%5D%20HTTP/2%20server%20push%20support%20in%20ext/curl%0A%0A%3ESupport%20for%20server%20push%20has%20been%20added%20to%20the%20CURL%20extension%20%28requires%20version%207.46%20and%20above%29.%20This%20can%20be%20leveraged%20through%20the%20curl_multi_setopt%28%29%20function%20with%20the%20new%20CURLMOPT_PUSHFUNCTION%20constant.%20The%20constants%20CURL_PUSH_OK%20and%20CURL_PUSH_DENY%20have%20also%20been%20added%20so%20that%20the%20execution%20of%20the%20server%20push%20callback%20can%20either%20be%20approved%20or%20denied.%0A%0A%60%60%60php%0A%24mh%20%3D%20curl_multi_init%28%29%3B%0A%0Acurl_multi_setopt%28%24mh%2C%20CURLMOPT_PIPELINING%2C%20CURLPIPE_MULTIPLEX%29%3B%0Acurl_multi_setopt%28%24mh%2C%20CURLMOPT_PUSHFUNCTION%2C%20%24callback%29%3B%0A%0A%24callback%20%3D%20function%28%24parent_ch%2C%20%24pushed_ch%2C%20array%20%24headers%29%20%7B%0A%09return%20CURL_PUSH_OK%3B%0A%7D%3B%0A%60%60%60%0A%0A%3E%20%5BRFC%5D%20https%3A//wiki.php.net/rfc/curl_http2_push%0A%0A%23%23%23%20%5B7.1%5D%20Asynchronous%20signal%20handling%0A%0A%3E%20A%20new%20function%20called%20pcntl_async_signals%28%29%20has%20been%20introduced%20to%20enable%20asynchronous%20signal%20handling%20without%20using%20ticks%20%28which%20introduce%20a%20lot%20of%20overhead%29.%0A%0A%60%60%60php%0Apcntl_async_signals%28true%29%3B%20//%20turn%20on%20async%20signals%0A%0Apcntl_signal%28SIGHUP%2C%20%20function%28%24sig%29%20%7B%0A%20%20%20%20echo%20%22SIGHUP%5Cn%22%3B%0A%7D%29%3B%0A%0Aposix_kill%28posix_getpid%28%29%2C%20SIGHUP%29%3B%0A%60%60%60%0A%0A%3E%20https%3A//github.com/Seldaek/signal-handler%0A%0A%23%23%23%20%5B7.1%5D%20Convert%20callables%20to%20Closures%20with%20Closure%3A%3AfromCallable%28%29%0A%0A%60%60%60php%0Aclass%20Test%0A%7B%0A%20%20%20%20public%20function%20exposeFunction%28%29%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20return%20Closure%3A%3AfromCallable%28%5B%24this%2C%20%27privateFunction%27%5D%29%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20private%20function%20privateFunction%28%24param%29%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20var_dump%28%24param%29%3B%0A%20%20%20%20%7D%0A%7D%0A%0A%24privFunc%20%3D%20%28new%20Test%29-%3EexposeFunction%28%29%3B%0A%24privFunc%28%27some%20value%27%29%3B%0A%60%60%60%0A%0A%23%23%23%20%5B7.1%5D%20Support%20for%20negative%20string%20offsets%0A%0A%3E%20Support%20for%20negative%20string%20offsets%20has%20been%20added%20to%20the%20string%20manipulation%20functions%20accepting%20offsets%2C%20as%20well%20as%20to%20string%20indexing%20with%20%5B%5D%20or%20%7B%7D.%20In%20such%20cases%2C%20a%20negative%20offset%20is%20interpreted%20as%20being%20an%20offset%20from%20the%20end%20of%20the%20string.%0A%0A%60%60%60php%0Avar_dump%28%22abcdef%22%5B-2%5D%29%3B%0Avar_dump%28strpos%28%22aabbcc%22%2C%20%22b%22%2C%20-3%29%29%3B%0A%0A%24string%20%3D%20%27bar%27%3B%0Aecho%20%22The%20last%20character%20of%20%27%24string%27%20is%20%27%24string%5B-1%5D%27.%5Cn%22%3B%0A%60%60%60%0A%0A%60%60%60%0Astring%20%281%29%20%22e%22%0Aint%283%29%0AThe%20last%20character%20of%20%27bar%27%20is%20%27r%27.%0A%60%60%60%0A%0A%0A%23%23%23%20%5B7.1%5D%20Support%20for%20keys%20in%20list%28%29%0A%0A%60%60%60php%0A%24data%20%3D%20%5B%0A%20%20%20%20%5B%22id%22%20%3D%3E%201%2C%20%22name%22%20%3D%3E%20%27Tom%27%5D%2C%0A%20%20%20%20%5B%22id%22%20%3D%3E%202%2C%20%22name%22%20%3D%3E%20%27Fred%27%5D%2C%0A%5D%3B%0A%0A//%20list%28%29%20style%0Alist%28%22id%22%20%3D%3E%20%24id1%2C%20%22name%22%20%3D%3E%20%24name1%29%20%3D%20%24data%5B0%5D%3B%0A%0A//%20%5B%5D%20style%0A%5B%22id%22%20%3D%3E%20%24id1%2C%20%22name%22%20%3D%3E%20%24name1%5D%20%3D%20%24data%5B0%5D%3B%0A%0A//%20list%28%29%20style%0Aforeach%20%28%24data%20as%20list%28%22id%22%20%3D%3E%20%24id%2C%20%22name%22%20%3D%3E%20%24name%29%29%20%7B%0A%20%20%20%20//%20logic%20here%20with%20%24id%20and%20%24name%0A%7D%0A%0A//%20%5B%5D%20style%0Aforeach%20%28%24data%20as%20%5B%22id%22%20%3D%3E%20%24id%2C%20%22name%22%20%3D%3E%20%24name%5D%29%20%7B%0A%20%20%20%20//%20logic%20here%20with%20%24id%20and%20%24name%0A%7D%0A%60%60%60%0A%0A%23%23%23%20%5B7.1%5D%20Multi%20catch%20exception%20handling%0A%0A%60%60%60php%0Atry%20%7B%0A%20%20%20%20//%20some%20code%0A%7D%20catch%20%28FirstException%20%7C%20SecondException%20%24e%29%20%7B%0A%20%20%20%20//%20handle%20first%20and%20second%20exceptions%0A%7D%0A%60%60%60%0A%0A%23%23%23%20%5B7.1%5D%20Iterable%20pseudo-type%0A%0A%60%60%60php%0Afunction%20iterator%28iterable%20%24iter%29%0A%7B%0A%20%20%20%20foreach%20%28%24iter%20as%20%24val%29%20%7B%0A%20%20%20%20%20%20%20%20//%0A%20%20%20%20%7D%0A%7D%0A%60%60%60%0A%0A%23%23%23%20%5B7.1%5D%20Class%20constant%20visibility%20%0A%0A%60%60%60php%0Aclass%20ConstDemo%0A%7B%0A%20%20%20%20const%20PUBLIC_CONST_A%20%3D%201%3B%0A%20%20%20%20public%20const%20PUBLIC_CONST_B%20%3D%202%3B%0A%20%20%20%20protected%20const%20PROTECTED_CONST%20%3D%203%3B%0A%20%20%20%20private%20const%20PRIVATE_CONST%20%3D%204%3B%0A%7D%0A%60%60%60%0A%0A%23%23%23%20%5B7.1%5D%20Void%20functions%0A%0A%60%60%60php%0Afunction%20swap%28%26%24left%2C%20%26%24right%29%20%3A%20void%0A%7B%0A%20%20%20%20if%20%28%24left%20%3D%3D%3D%20%24right%29%20%7B%0A%20%20%20%20%20%20%20%20return%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20%24tmp%20%3D%20%24left%3B%0A%20%20%20%20%24left%20%3D%20%24right%3B%0A%20%20%20%20%24right%20%3D%20%24tmp%3B%0A%7D%0A%0A%24a%20%3D%201%3B%0A%24b%20%3D%202%3B%0Avar_dump%28swap%28%24a%2C%20%24b%29%2C%20%24a%2C%20%24b%29%3B%0A%60%60%60%0A%0A%23%23%23%20%5B7.1%5D%20Symmetric%20array%20destructuring%0A%0A%60%60%60php%0A%24data%20%3D%20%5B%0A%20%20%20%20%5B1%2C%20%27Tom%27%5D%2C%0A%20%20%20%20%5B2%2C%20%27Fred%27%5D%2C%0A%5D%3B%0A%0A//%20list%28%29%20style%0Alist%28%24id1%2C%20%24name1%29%20%3D%20%24data%5B0%5D%3B%0A%0A//%20%5B%5D%20style%0A%5B%24id1%2C%20%24name1%5D%20%3D%20%24data%5B0%5D%3B%0A%0A//%20list%28%29%20style%0Aforeach%20%28%24data%20as%20list%28%24id%2C%20%24name%29%29%20%7B%0A%20%20%20%20//%20logic%20here%20with%20%24id%20and%20%24name%0A%7D%0A%0A//%20%5B%5D%20style%0Aforeach%20%28%24data%20as%20%5B%24id%2C%20%24name%5D%29%20%7B%0A%20%20%20%20//%20logic%20here%20with%20%24id%20and%20%24name%0A%7D%0A%60%60%60%0A%0A%60%60%60%0Anull%0Aint%282%29%0Aint%281%29%0A%60%60%60%0A%0A%23%23%23%20%5B7.1%5D%20Nullable%20types%0A%0A%60%60%60php%0A%0Afunction%20testReturn%28%29%3A%20%3Fstring%0A%7B%0A%20%20%20%20return%20%27elePHPant%27%3B%0A%7D%0A%0Avar_dump%28testReturn%28%29%29%3B%0A%0Afunction%20testReturn%28%29%3A%20%3Fstring%0A%7B%0A%20%20%20%20return%20null%3B%0A%7D%0A%0Avar_dump%28testReturn%28%29%29%3B%0A%0Afunction%20test%28%3Fstring%20%24name%29%0A%7B%0A%20%20%20%20var_dump%28%24name%29%3B%0A%7D%0A%0Atest%28%27elePHPant%27%29%3B%0Atest%28null%29%3B%0Atest%28%29%3B%0A%60%60%60%0A%0A%60%60%60%0Astring%2810%29%20%22elePHPant%22%0ANULL%0Astring%2810%29%20%22elePHPant%22%0ANULL%0AUncaught%20Error%3A%20Too%20few%20arguments%20to%20function%20test%28%29%2C%200%20passed%20in...%0A%60%60%60%0A%0A%23%23%23%20%5B7.0%5D%20Scalar%20type%20declarations%20%0A%0A%60%60%60%20php%0A%3C%3Fphp%0Adeclare%28strict_type%3D1%29%3B%0A%0Afunction%20test%28int%20%24integer%2C%20bool%20%24bool%2C%20floar%20%24float%2C%20string%20%24string%29%0A%7B%0A%0A%7D%0A%60%60%60%0A%0A%23%23%23%20%5B7.0%5D%20Return%20type%20declarations%0A%0A%60%60%60php%0A%3C%3Fphp%0A%0Afunction%20arraysSum%28array%20...%24arrays%29%3A%20array%0A%7B%0A%20%20%20%20return%20array_map%28function%28array%20%24array%29%3A%20int%20%7B%0A%20%20%20%20%20%20%20%20return%20array_sum%28%24array%29%3B%0A%20%20%20%20%7D%2C%20%24arrays%29%3B%0A%7D%0A%0A%60%60%60%0A%0A%23%23%23%20%5B7.0%5D%20Null%20coalescing%20operator%0A%0A%60%60%60php%0A%24username%20%3D%20%24_GET%5B%27user%27%5D%20%3F%3F%20%24_POST%5B%27user%27%5D%20%3F%3F%20%27nobody%27%3B%0A%60%60%60%0A%0A%23%23%23%20%5B7.0%5D%20Spaceship%20operator%0A%0A%60%60%60php%0A%3C%3Fphp%0A//%20Integers%0Aecho%201%20%3C%3D%3E%201%3B%20//%200%0Aecho%201%20%3C%3D%3E%202%3B%20//%20-1%0Aecho%202%20%3C%3D%3E%201%3B%20//%201%0A%0A//%20Floats%0Aecho%201.5%20%3C%3D%3E%201.5%3B%20//%200%0Aecho%201.5%20%3C%3D%3E%202.5%3B%20//%20-1%0Aecho%202.5%20%3C%3D%3E%201.5%3B%20//%201%0A%20%0A//%20Strings%0Aecho%20%22a%22%20%3C%3D%3E%20%22a%22%3B%20//%200%0Aecho%20%22a%22%20%3C%3D%3E%20%22b%22%3B%20//%20-1%0Aecho%20%22b%22%20%3C%3D%3E%20%22a%22%3B%20//%201%0A%3F%3E%0A%60%60%60%0A%0A%23%23%23%20%5B7.0%5D%20Constant%20arrays%20using%20define%28%29%0A%0A%60%60%60php%0A%3C%3Fphp%0Adefine%28%27ANIMALS%27%2C%20%5B%0A%20%20%20%20%27dog%27%2C%0A%20%20%20%20%27cat%27%2C%0A%20%20%20%20%27bird%27%0A%5D%29%3B%0A%0Aecho%20ANIMALS%5B1%5D%3B%20//%20outputs%20%22cat%22%0A%3F%3E%0A%60%60%60%0A%0A%23%23%23%20%5B7.0%5D%20Anonymous%20classes%0A%0A%60%60%60php%0A%3C%3Fphp%0A%0A%24app%20%3D%20new%20Application%3B%0A%24app-%3EsetLogger%28new%20class%20implements%20Logger%20%7B%0A%20%20%20%20public%20function%20log%28string%20%24msg%29%20%7B%0A%20%20%20%20%20%20%20%20echo%20%24msg%3B%0A%20%20%20%20%7D%0A%7D%29%3B%0A%0Avar_dump%28%24app-%3EgetLogger%28%29%29%3B%0A%3F%3E%0A%60%60%60%0A%0A%23%23%23%20%5B7.0%5D%20Unicode%20codepoint%20escape%20syntax%0A%0A%3E%20This%20takes%20a%20Unicode%20codepoint%20in%20hexadecimal%20form%2C%20and%20outputs%20that%20codepoint%20in%20UTF-8%20to%20a%20double-quoted%20string%20or%20a%20heredoc.%20Any%20valid%20codepoint%20is%20accepted%2C%20with%20leading%200%27s%20being%20optional.%0A%0A%60%60%60php%0Aecho%20%22%5Cu%7Baa%7D%22%3B%0Aecho%20%22%5Cu%7B0000aa%7D%22%3B%0Aecho%20%22%5Cu%7B9999%7D%22%3B%0A%60%60%60%0A%0A%60%60%60%0A%AA%0A%AA%20%28same%20as%20before%20but%20with%20optional%20leading%200%27s%29%0A%u9999%0A%60%60%60%0A%0A%23%23%23%20%5B7.0%5D%20Closure%3A%3Acall%28%29%0A%0A%5BClosure%3A%3Acall%28%29%5D%28http%3A//php.net/manual/fr/closure.call.php%29%20is%20a%20more%20performant%2C%20shorthand%20way%20of%20temporarily%20binding%20an%20object%20scope%20to%20a%20closure%20and%20invoking%20it.%0A%0A%60%60%60php%0A%3C%3Fphp%0Aclass%20A%20%7Bprivate%20%24x%20%3D%201%3B%7D%0A%0A//%20Pre%20PHP%207%20code%0A%24getXCB%20%3D%20function%28%29%20%7Breturn%20%24this-%3Ex%3B%7D%3B%0A%24getX%20%3D%20%24getXCB-%3EbindTo%28new%20A%2C%20%27A%27%29%3B%20//%20intermediate%20closure%0Aecho%20%24getX%28%29%3B%0A%0A//%20PHP%207+%20code%0A%24getX%20%3D%20function%28%29%20%7Breturn%20%24this-%3Ex%3B%7D%3B%0Aecho%20%24getX-%3Ecall%28new%20A%29%3B%0A%60%60%60%0A%0A%23%23%23%20%5B7.0%5D%20Filtered%20unserialize%28%29%0A%0A%3E%20This%20feature%20seeks%20to%20provide%20better%20security%20when%20unserializing%20objects%20on%20untrusted%20data.%20It%20prevents%20possible%20code%20injections%20by%20enabling%20the%20developer%20to%20whitelist%20classes%20that%20can%20be%20unserialized.%20%0A%0A%60%60%60php%0A//%20converts%20all%20objects%20into%20__PHP_Incomplete_Class%20object%0A%24data%20%3D%20unserialize%28%24foo%2C%20%5B%22allowed_classes%22%20%3D%3E%20false%5D%29%3B%0A%0A//%20converts%20all%20objects%20into%20__PHP_Incomplete_Class%20object%20except%20those%20of%20MyClass%20and%20MyClass2%0A%24data%20%3D%20unserialize%28%24foo%2C%20%5B%22allowed_classes%22%20%3D%3E%20%5B%22MyClass%22%2C%20%22MyClass2%22%5D%5D%29%3B%0A%0A//%20default%20behaviour%20%28same%20as%20omitting%20the%20second%20argument%29%20that%20accepts%20all%20classes%0A%24data%20%3D%20unserialize%28%24foo%2C%20%5B%22allowed_classes%22%20%3D%3E%20true%5D%29%3B%0A%60%60%60%0A%0A%23%23%23%20%5B7.0%5D%20Group%20use%20declarations%0A%0A%60%60%60php%0Ause%20some%5Cnamespace%5C%7BClassA%2C%20ClassB%2C%20ClassC%20as%20C%7D%3B%0Ause%20function%20some%5Cnamespace%5C%7Bfn_a%2C%20fn_b%2C%20fn_c%7D%3B%0Ause%20const%20some%5Cnamespace%5C%7BConstA%2C%20ConstB%2C%20ConstC%7D%3B%0A%60%60%60%0A%0A%23%23%23%20%5B7.0%5D%20list%28%29%20can%20always%20unpack%20objects%20implementing%20ArrayAccess%0A%0A%3E%20Previously%2C%20list%28%29%20was%20not%20guaranteed%20to%20operate%20correctly%20with%20objects%20implementing%20ArrayAccess.%20This%20has%20been%20fixed.%0A%0A%23%23%23%20%5B7.0%5D%20preg_replace_callback_array%28%29%0A%0A%3E%20The%20new%20%5Bpreg_replace_callback_array%28%29%5D%28http%3A//php.net/manual/fr/function.preg-replace-callback-array.php%29%20function%20enables%20code%20to%20be%20written%20more%20cleanly%20when%20using%20the%20preg_replace_callback%28%29%20function.%20Prior%20to%20PHP%207%2C%20callbacks%20that%20needed%20to%20be%20executed%20per%20regular%20expression%20required%20the%20callback%20function%20to%20be%20polluted%20with%20lots%20of%20branching.%0A%0ANow%2C%20callbacks%20can%20be%20registered%20to%20each%20regular%20expression%20using%20an%20associative%20array%2C%20where%20the%20key%20is%20a%20regular%20expression%20and%20the%20value%20is%20a%20callback.%0A%0A%23%23%23%20%5B7.0%5D%20Integer%20division%20with%20intdiv%28%29%0A%0A%3E%20The%20new%20%5Bintdiv%28%29%5D%28http%3A//php.net/manual/fr/function.intdiv.php%29%20function%20performs%20an%20integer%20division%20of%20its%20operands%20and%20returns%20it.%0A%0A%60%60%60php%0Avar_dump%28intdiv%283%2C%202%29%29%3B%0Avar_dump%283/2%29%3B%0A%60%60%60%0A%0A%60%60%60%0Aint%281%29%0Afloat%281.5%29%0A%60%60%60%0A%09%0A%0A%23%23%20%20PHP%20Major%20migration%0A%0A%7C%20Version%20%20%20%20%20%20%7C%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7C%0A%7C%20%3A----------%20%7C%20----------------------------------------------------------------------------------%3A%7C%0A%7C%207.0%20-%3E%207.1%20%20%7C%5Bhttp%3A//php.net/manual/fr/migration71.php%5D%28http%3A//php.net/manual/fr/migration71.php%29%7C%0A%7C%205.6%20-%3E%207.0%20%20%7C%5Bhttp%3A//php.net/manual/fr/migration70.php%5D%28http%3A//php.net/manual/fr/migration70.php%29%7C%20%0A%7C%205.5%20-%3E%205.6%20%20%7C%5Bhttp%3A//php.net/manual/fr/migration56.php%5D%28http%3A//php.net/manual/fr/migration56.php%29%7C%20%0A%0A%0A%23%23%20Tips%20%28There%20are%20micro%20optimizations%29%0A%0A%23%23%23%20%20%5B7%5D%20Packed%20arrays%0A%0A%3EPacked%20arrays%20is%20the%20first%20great%20PHP%207%20optimization.%20Packed%20arrays%20consume%20less%20memory%20and%20are%20a%20bit%20faster%20in%20many%20operations%20than%20traditional%20arrays.%20A%20packed%20array%20must%20have%20the%20following%20characteristics%3A%0A*%20The%20keys%20are%20only%20integers%3B%0A*%20The%20keys%20are%20inserted%20into%20the%20array%20in%20growing%20only%20mode.%0A%60%60%60php%0A%24a%20%3D%20%5B%27foo%27%2C%20%27bar%27%2C%20%27baz%27%5D%3B%0A%24a%20%3D%20%5B12%20%3D%3E%20%27baz%27%2C%2042%20%3D%3E%20%27bar%27%2C%2067%20%3D%3E%20%5B%5D%20%5D%3B%0A%60%60%60%0A%0A%3E%20**TIPS**%20%20%60%24pdo-%3Equery%28%22SELECT%20*%20FROM%20table%20LIMIT%2010000%22%29-%3EfetchAll%28PDO%3A%3AFETCH_NUM%29%60%20%0A%0A%23%23%23%20%5B7%5D%20ints/floats%20are%20free%0A%0A%3E%20In%20PHP%207%2C%20the%20way%20variables%20are%20allocated%20in%20memory%20changed%20dramatically.%20They%20went%20from%20being%20stored%20on%20the%20heap%20to%20stack%20memory%20pools.%20As%20a%20side%20effect%2C%20you%20may%20reuse%20variable%20containers%20for%20free%3A%20no%20memory%20allocated.%20That%u2019s%20impossible%20to%20do%20in%20PHP%205%2C%20where%20each%20variable%20creation/assignment%20requires%20some%20memory%20allocation%20%28which%20is%20bad%20for%20performance%29.%0A%0A%0A%60%60%60php%0Afor%20%28%24i%3D0%3B%20%24i%3C10000%3B%20%24i++%29%20%7B%0A%09%24%24i%20%3D%20%27foo%27%3B%0A%7D%0A%60%60%60%0A**VS**%0A%60%60%60php%0Afor%20%28%24i%3D0%3B%20%24i%3C10000%3B%20%24i++%29%20%7B%0A%09%24%24i%20%3D%2042%3B%0A%7D%0A%60%60%60%0A%0A%21%5BAlt%20text%5D%28./variable-integer.png%29%0A%0A%0A%23%23%23%20%5B7%5D%20References%20mismatch%0A%0AReference%20mismatch%20happens%20when%20you%20pass%20a%20non-ref%20variable%20to%20a%20function%20argument%20passed-by-ref%2C%20or%20the%20opposite.%20Something%20like%20this%3A%0A%0A%60%60%60php%0Afunction%20foo%28%26%24arg%29%20%7B%20%7D%0A%24var%20%3D%20%27str%27%3B%0Afoo%28%24var%29%3B%0A%60%60%60%0A%0ADo%20you%20know%20what%20horrible%20things%20happen%20under%20the%20hood%20in%20the%20PHP%205%20engine%3F%20In%20PHP%205%2C%20whenever%20there%20is%20a%20reference%20mismatch%2C%20the%20engine%20is%20forced%20to%20duplicate%20the%20variable%20before%20passing%20it%20as%20an%20argument%20to%20a%20function.%20As%20you%20probably%20guessed%2C%20if%20the%20variable%20contains%20something%20big%2C%20like%20a%20several-thousands-entries%20array%20or%20a%20big%20chunk%20of%20string%3B%20the%20copy%20will%20take%20a%20lot%20of%20time.%0A%0AThis%20is%20because%20of%20the%20way%20variables%20and%20references%20used%20to%20work%20into%20PHP%205.%20When%20going%20into%20the%20body%20function%2C%20the%20engine%20doesn%u2019t%20know%20yet%20if%20you%20will%20change%20the%20argument%20value.%20If%20you%20are%2C%20then%20as%20the%20argument%20is%20taken%20by%20reference%2C%20the%20change%20must%20be%20reflected%20outside%20if%20a%20reference%20variable%20were%20passed.%20What%20if%20it%20was%20not%20the%20case%20%28as%20in%20our%20example%29%3F%20The%20engine%20must%20then%20create%20a%20reference%2C%20from%20the%20non-reference%20variable%20you%20passed%20it%20in%20the%20function%20call.%20This%20procedure%20leads%20the%20engine%20to%20fully%20duplicate%20the%20variable%20content%20in%20PHP%205%20%28calling%20a%20lot%20of%20memcpy%28%29%20on%20very%20sparse%20pointers%2C%20leading%20to%20tons%20of%20slow%20memory%20accesses%29.%0A%0AIn%20PHP%207%2C%20when%20the%20engine%20wants%20to%20create%20a%20reference%20from%20a%20non-reference%20variable%2C%20it%20just%20wraps%20the%20latter%20into%20the%20newly%20created%20former%2C%20that%u2019s%20all.%20There%20is%20no%20memory%20copy%2C%20anywhere.%20This%20is%20because%20variables%20work%20in%20a%20very%20different%20way%20internally%20in%20PHP%207%2C%20and%20references%20have%20been%20deeply%20reworked.%0A%0ALook%20at%20this%20piece%20of%20code%3A%0A%0A%60%60%60php%0Afunction%20bar%28%26%24a%29%20%7B%20%24f%20%3D%20%24a%3B%20%7D%0A%20%0A%24var%20%3D%20range%281%2C1024%29%3B%0A%20%0Afor%20%28%24i%3D0%3B%20%24i%3C1000%3B%20%24i++%29%20%7B%0Abar%28%24var%29%3B%0A%7D%0A%60%60%60%0A%0AThere%20is%20a%20double%20mismatch.%20When%20you%20call%20bar%28%29%2C%20you%20force%20the%20engine%20to%20create%20a%20reference%20from%20%60%24var%60%20%20to%20%60%24a%60%20%2C%20as%20the%20signature%20says%20%60%26%24a%60.%20Then%2C%20now%20that%20%60%24a%60%20is%20part%20of%20a%20reference%20set%20%28%60%24var-%24a%60%29%20into%20the%20bar%28%29%20body%2C%20you%20affect%20it%20by%20value%20to%20%60%24f%60%3A%20this%20is%20another%20mismatch.%20%60%24f%60%20is%20not%20affected%20by%20reference%2C%20so%20%60%24a-%24f-%24var%60%20must%20not%20be%20linked%20together%2C%20but%20%60%24var-%24a%60%20in%20one%20part%2C%20and%20%60%24f%60%20alone%20in%20another%20part%3A%20you%20once%20more%20force%20the%20engine%20to%20perform%20some%20copies.%20In%20PHP%207%2C%20creating%20variables%20to/from%20references%20is%20pretty%20light%2C%20only%20copy-on-write%20may%20happen%20after%20that.%0A%0A%21%5BAlt%20text%5D%28./ref-mis.png%29%0A%0A%0A%23%23%23%20%5B7%5D%20Immutable%20arrays%0A%0AImmutable%20arrays%20are%20a%20concept%20added%20to%20PHP%207%2C%20and%20part%20of%20the%20OPCache%20extension%2C%20which%20I%20assume%20you%20are%20using.%20An%20immutable%20array%20is%20an%20array%20full%20of%20immutable%20elements%2C%20which%20are%20compile-time%20known%20and%20fully%20resolved%20values%3A%20strings%2C%20integers%2C%20floats%2C%20or%20arrays%20containing%20those.%20In%20a%20word%3A%20no%20dynamic%20elements%2C%20no%20variables%2C%20like%20in%20this%20example%3A%0A%0A%60%60%60php%0A%24ar%20%3D%20%5B%20%27foo%27%2C%2042%2C%20%27bar%27%2C%20%5B1%2C%202%2C%203%5D%2C%209.87%20%5D%3B%0A%60%60%60%0A%0ASuch%20arrays%20have%20been%20optimized%20in%20PHP%207.%20Under%20PHP%205%2C%20those%20are%20just%20plain%20arrays%2C%20there%20is%20no%20difference%20between%20an%20array%20containing%20dynamic%20members%20%28such%20as%20%60%24vars%60%29%2C%20and%20a%20static%20compile-time%20resolved%20array.%20In%20PHP%207%2C%20immutable%20arrays%20are%20not%20copied%20nor%20duplicated%20as%20soon%20as%20they%20stay%20read%20only.%0A%0AHere%20is%20such%20an%20example%3A%0A%0A%60%60%60php%0Afor%20%28%24i%20%3D%200%3B%20%24i%20%3C%201000%3B%20%24i++%29%20%7B%0A%24var%5B%5D%20%3D%20%5B%0A%20%200%20%3D%3E%20%27Symfony%5C%5CBundle%5C%5CFrameworkBundle%5C%5CEventListener%5C%5CSessionListener%27%2C%0A%20%201%20%3D%3E%20%27Symfony%5C%5CComponent%5C%5CHttpFoundation%5C%5CSession%5C%5CStorage%5C%5CNativeSessionStorage%27%2C%0A%20%20/*%20...%20go%20to%20many%20immutable%20items%20here%20*/%0A%20%20%5D%3B%0A%7D%0A%60%60%60%0A%0AThe%20above%20code%20creates%20the%20same%20big%20array%201%2C000%20times%20%28truncated%2C%20think%20of%20it%20as%20being%20a%20hundred%20or%20thousand%20slots%20array%29.%0A%0AIn%20PHP%205%2C%20this%20array%20is%20duplicated%20in%20memory%201%2C000%20times.%20A%20big%20array%20could%20weight%20at%20several%20hundreds%20of%20Kilobytes%20or%20even%20Megabytes%2C%20which%20in%20this%20code%20will%20be%20duplicated%201%2C000%20times.%20Such%20a%20waste%20of%20memory.%0A%0AIn%20PHP%207%2C%20OPCache%20flags%20those%20arrays%20as%20being%20immutable%3A%20the%20array%20is%20created%20only%20once%2C%20and%20shares%20its%20memory%20pointer%20everywhere%20it%20is%20supposed%20to%20be%20used%2C%20ending%20in%20huge%20savings%20of%20overall%20memory%2C%20especially%20when%20dealing%20with%20big%20configuration%20arrays%2C%20like%20the%20one%20shown%20in%20the%20example%20%28which%20is%20taken%20from%20the%20Symfony%203%20framework%29.%0A%0ALet%u2019s%20see%20the%20performance%20impact%3A%0A%0A%21%5BAlt%20text%5D%28./immutable-arrays.png%29%0A%0A%3E%20Illustrated%20example%20with%20composer%20%3A%20https%3A//github.com/composer/composer/pull/5174%0A%0A%21%5BAlt%20text%5D%28./Screenshot%20Thu%20Dec%2022%202016%2011%3A34%3A35%20GMT+0100%20CET%201517x1036.png%29%0A%0A%0A%0A&lt;/center&gt;&lt;br/&gt;&lt;/div&gt;
</content>
  </entry>
</feed>
