Is there any difference between PHP registered in checks

I saw both of them in scripts and wondered from a security point of view if one outweighs the other? Is it better to include the content of a secure page in an IF statement?

if(!login_check($mysqli)) {
    header("Location: index.php"); 
    exit;
}

//Secure Page Content.

Or...

if (login_check($mysqli)) {

    //Secure Page Content.

} else { 
    header("Location: index.php");
}
exit;
+3
source share
2 answers

Strictly from a security point, I would not say the difference. What, as they say. The first is much clearer to read. If the content of the page is larger than the screen, you have lost information about where the legend ends. This can lead to an error in the place where the other is executed, and the page becomes open.

, , , , .

+1

: ?

1:

function (a, b, c) {
    if (a < b) {
        return a;
    }
    return c;
}

2:

function (a, b, c) {
    var result;
    if (a < b) {
        result = a;
    } else {
        result = c;
    }
    return result;
}

. , , .

+2

All Articles