I found 2 ways to block direct access to php files (although it's not always necessary, see https://wordpress.stackexchange.com/a/63004/60539) The first one is:
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
And the other:
if ( ! empty( $_SERVER['SCRIPT_FILENAME'] ) && basename( __FILE__ ) == basename( $_SERVER['SCRIPT_FILENAME'] ) ) {
die ( 'You do not have sufficient permissions to access this page!' );
}
Are they doing the same thing? Shall I prefer one to the other?