Should PHP code be saved in a PHP file or an HTML file?

PHP code should be saved in a PHP file rather than an HTML file. This is because PHP code needs to be processed by the server before it is sent to the client's browser, and this processing can only be done in a PHP file. To ensure that your PHP code works correctly, save it in a file with a .php extension.

<?php
// Your PHP code here
?>