What are best practices for saving PHP files to avoid introducing extra spaces before the doctype declaration?

Extra spaces before the doctype declaration can cause issues with headers already being sent in PHP. To avoid this problem, it is best practice to ensure that there are no spaces or characters before the opening <?php tag in your PHP files.

&lt;?php
// Your PHP code here