Does a simple `return` in a PHP function simply end the function prematurely?

前端 未结 5 1677
梦毁少年i
梦毁少年i 2021-02-14 00:43

I have just seen this

// Check to see if the request is a XHR call    
if (request::is_ajax())
{
  // Send the 403 header
  header(\'HTTP/1.1 403 Forbidden\');
          


        
5条回答
  •  日久生厌
    2021-02-14 01:20

    Short answer. It just ends the function, its much like a function with no return statement. Nothing is returned, the function is just exited.

    In your second example, $var would = nothing.

    Why not execute it and see?

提交回复
热议问题