Results of 1 - 1 of about 1 for Bienvenue (0.001 sec.)
- match | PHP 8.3 9414
- match (PHP 8) match 式は、値の一致をチェックした結果に基づいて評価結果を分岐します。 switch 文と似ていますが、 match 式は複数の候補と比較される制約式を持ちます。 switch 文とは異なり、 三項演算子のように値を評価します。 switch 文とは異なり、
... 例の出力は以下となります。 string(11) "young adult" 例6 文字列の内容に応じてmatch式を分岐させる一般的な使い方 <?php $text = 'Bienvenue chez nous' ; $result = match ( true ) { str_contains ( $text , 'Welcome' ), str_contains ( $text , 'Hello' ) => 'en' , str ... _contains ( $text , 'Bienvenue' ), str_contains ( $text , 'Bonjour' ) => 'fr' , // ... }; var_dump ( $result ); 上の例の出力は以下となります。 string(2) ...
-
https://man.mtool.work/php/8.3/control-structures.match.html
PREV
1
NEXT