When building a plugin, themes or for some security reasons that you might want to prevent direct access to your PHP file you may use the following code:
For WordPress
if( ! defined( 'ABSPATH' ) ) exit;
For Osclass
if( ! defined( 'ABS_PATH' ) ) exit( 'No direct script access allowed' );