What is the best way to automatically execute a PHP file that is included using src without directly calling it in the code?

To automatically execute a PHP file that is included using src without directly calling it in the code, you can use an .htaccess file to rewrite the URL to the included PHP file. This way, when the src attribute is used to include the PHP file in an HTML document, the server will automatically execute the PHP file without the need for direct calls in the code.

RewriteEngine on
RewriteRule ^included-file.php$ - [L]
RewriteRule ^included-file-src$ included-file.php [L]