11<?xml version =" 1.0" encoding =" utf-8" ?>
22<!-- $Revision$ -->
3- <!-- EN-Revision: 6c71b05df89358d7760a4740ed3fcfa1682eadb6 Maintainer: mumumu Status: ready -->
3+ <!-- EN-Revision: 17502ebe0691a84e7d0738c13e8c1061dde98de7 Maintainer: mumumu Status: ready -->
44
55<sect1 xml : id =" control-structures.match" xmlns =" http://docbook.org/ns/docbook" xmlns : xlink =" http://www.w3.org/1999/xlink" >
66 <title >match</title >
@@ -66,8 +66,8 @@ $output = match (true) {
6666 $age < 2 => "Baby",
6767 $age < 13 => "Child",
6868 $age <= 19 => "Teenager",
69+ $age >= 40 => "Old adult",
6970 $age > 19 => "Young adult",
70- $age >= 40 => "Old adult"
7171};
7272
7373var_dump($output);
@@ -89,7 +89,7 @@ string(8) "Teenager"
8989 </note >
9090 <note >
9191 <simpara >
92- <literal >match</literal > 式は 、必ずセミコロン <literal >;</literal > で終わらなければなりません。
92+ <literal >match</literal > 式を単一の式として使う場合は 、必ずセミコロン <literal >;</literal > で終わらなければなりません。
9393 </simpara >
9494 </note >
9595 </example >
@@ -137,8 +137,8 @@ string(8) "Teenager"
137137<![CDATA[
138138<?php
139139$result = match ($x) {
140- foo() => ... ,
141- $this->bar() => ... , // foo() === $x であれば $this->bar() は呼び出されません。
140+ foo() => 'value' ,
141+ $this->bar() => 'value' , // foo() === $x であれば $this->bar() は呼び出されません
142142 $this->baz => beep(), // $x === $this->baz でなければ beep() は呼び出されません。
143143 // などなど
144144};
@@ -287,8 +287,8 @@ string(11) "young adult"
287287$text = 'Bienvenue chez nous';
288288
289289$result = match (true) {
290- str_contains($text, 'Welcome') || str_contains($text, 'Hello') => 'en',
291- str_contains($text, 'Bienvenue') || str_contains($text, 'Bonjour') => 'fr',
290+ str_contains($text, 'Welcome'), str_contains($text, 'Hello') => 'en',
291+ str_contains($text, 'Bienvenue'), str_contains($text, 'Bonjour') => 'fr',
292292 // ...
293293};
294294
0 commit comments