PHP - exit or return which is better?

后端 未结 4 716
日久生厌
日久生厌 2020-12-13 02:05

I would like to know in the following case which is a better option:

In the PHP script, if the $fileSize variable is larger than 100, I stop the script;

4条回答
  •  失恋的感觉
    2020-12-13 02:32

    It depends...if your script is intended to do nothing else but output a message, and you don't want the script to do anything afterwards, exit() will work. Otherwise, use return.

提交回复
热议问题