1
1
<?xml version =" 1.0" encoding =" utf-8" ?>
2
2
<!-- $Revision$ -->
3
- <!-- EN-Revision: 6c71b05df89358d7760a4740ed3fcfa1682eadb6 Maintainer: mumumu Status: ready -->
3
+ <!-- EN-Revision: 17502ebe0691a84e7d0738c13e8c1061dde98de7 Maintainer: mumumu Status: ready -->
4
4
5
5
<sect1 xml : id =" control-structures.match" xmlns =" http://docbook.org/ns/docbook" xmlns : xlink =" http://www.w3.org/1999/xlink" >
6
6
<title >match</title >
@@ -66,8 +66,8 @@ $output = match (true) {
66
66
$age < 2 => "Baby",
67
67
$age < 13 => "Child",
68
68
$age <= 19 => "Teenager",
69
+ $age >= 40 => "Old adult",
69
70
$age > 19 => "Young adult",
70
- $age >= 40 => "Old adult"
71
71
};
72
72
73
73
var_dump($output);
@@ -89,7 +89,7 @@ string(8) "Teenager"
89
89
</note >
90
90
<note >
91
91
<simpara >
92
- <literal >match</literal > 式は 、必ずセミコロン <literal >;</literal > で終わらなければなりません。
92
+ <literal >match</literal > 式を単一の式として使う場合は 、必ずセミコロン <literal >;</literal > で終わらなければなりません。
93
93
</simpara >
94
94
</note >
95
95
</example >
@@ -137,8 +137,8 @@ string(8) "Teenager"
137
137
<![CDATA[
138
138
<?php
139
139
$result = match ($x) {
140
- foo() => ... ,
141
- $this->bar() => ... , // foo() === $x であれば $this->bar() は呼び出されません。
140
+ foo() => 'value' ,
141
+ $this->bar() => 'value' , // foo() === $x であれば $this->bar() は呼び出されません
142
142
$this->baz => beep(), // $x === $this->baz でなければ beep() は呼び出されません。
143
143
// などなど
144
144
};
@@ -287,8 +287,8 @@ string(11) "young adult"
287
287
$text = 'Bienvenue chez nous';
288
288
289
289
$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',
292
292
// ...
293
293
};
294
294
0 commit comments