Results of 1 - 1 of about 1 for testReturnTry (0.001 sec.)
- finally | PHP 8.3 9414
- finally (PHP 5 >= 5.5.0, PHP 7, PHP 8) catch ブロックの後、またはその代わりに、 finally ブロックも指定できます。 finally ブロックの中に書いたコードは、 return 文や yield 文に到達した場合や、 Throwable エラーがキャッチされなかったり、 スロー
... は、 finally ブロックから値が返されます。 例3 finally ブロック内の return と、それより前の return の相互作用 <?php function testReturnTry () { try { echo 'Within try' , "\n" ; return 'try' ; } finally { echo 'Within finally' , "\n" ; return 'finally' ; } } fun ... e ) { echo 'Within catch' , "\n" ; return 'catch' ; } finally { echo 'Within finally' , "\n" ; return 'finally' ; } } echo testReturnTry (), "\n" ; echo testReturnCatch (), "\n" ; 上の例の出力は以下となります。 Within try Within finally finally Within catch W ... ithin finally finally 例4 finally ブロックと return の相互作用 <?php function testReturnTry () { try { return 'try' ; } finally { echo 'finally ' ; } } function testReturnCatch () { try { throw new Exception ( 'foo ...
-
https://man.mtool.work/php/8.3/control-structures.finally.html
PREV
1
NEXT