How can PHP developers ensure that PHP scripts are not visible to users when viewing the source code of a webpage?

PHP developers can ensure that PHP scripts are not visible to users when viewing the source code of a webpage by placing the sensitive PHP code in a separate file outside of the web root directory. This way, the PHP code cannot be accessed directly by users through the browser. Developers can then include the external PHP file using include or require statements within their HTML files to execute the PHP code.

// sensitive_script.php
<?php
// sensitive PHP code here
?>

// index.php
<?php
include 'sensitive_script.php';
?>