The only time your PHP code can be opened is if the script is somehow treated as "non-PHP" and receives the message as raw text. If your server configuration is correct, then the code is "safe" due to an Internet leak.
In this case, it is best to put critical information that must remain confidential (user names / passwords, configuration variables, DSN databases, etc.) in a separate file that stores OUTSIDE in the root of the documentβs site. Thus, even if PHP is damaged / disabled on the server, all that the user sees is
<?php include('critical_data_here.php'); ?>
but not
<?php $username = 'root'; $password = 'password'; $lotto_ticket_worth_50million = 'under the left couch cushion at 221B Baker Street'; ?>
source share