vendredi 28 août 2020

What does the return do at the end of the expression of a PHP condition?

I am analyzing a PHP code but I cannot understand the logic of a condition with a return at the end.

Route::domain('{name}.{domain}.{tls}')->group(function () {
    $settings = App::make(\Common\Settings\Settings::class);
    $appUrl = config('app.url');
    $currentUrl = \Request::url();
    if ($appUrl === $currentUrl || !$settings->get('builder.enable_subdomains')) return; //<- Here
    Route::get('{page?}', 'UserSiteController@show')->name('user-site-subdomain');
});

I need to understand what are the circumstances that line 6 will be executed but apparently the return changes everything.

Any clarification or some more illustrative example will be welcome.

Aucun commentaire:

Enregistrer un commentaire