Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
関数の最後に「return false」「exit」と書いてあるのを見たことがある。これら 2 つの主な違いは何ですか? また、これら 2 つが必要になるのはどのような状況ですか?
exit は PHP の実行を終了しますが、return は関数を終了します。ほとんどの場合、return を使用します。状況によって異なります。
「return」は関数の終了、「exit」はスクリプト全体の終了です。
出口の説明
返品の説明
return false関数exit用で、phpスクリプトを停止するためのものです
return false
exit
exit() は PHP プログラム全体を停止し、OS に戻ります。
一方、return は関数呼び出しを終了し、呼び出し元に戻ります。