Four Spaces Before <?php(brunopinto.dev)
brunopinto.dev
Four Spaces Before <?php
https://brunopinto.dev/four-spaces-before-php/
2 comments
Correct. Every char outside of a php tag is treated as output, like in a templating engine. So if you start with spaces in a non template file (class definition etc) the spaces will be sent as output which messes up the http response.
Id love to have a dedicated file extension for source files only, like .p or something that disables the php tags because in this day and age the vast majority of php files aren’t templates
Id love to have a dedicated file extension for source files only, like .p or something that disables the php tags because in this day and age the vast majority of php files aren’t templates
At the very least, a quick boo through some pretty vintage files of mine shows that every PHP file starts out without spaces or blank newlines - `<?php` is the very first thing encountered. So clearly there was formatting discipline there, but whether it came down to specific reasoning or not is the real question, and one I cannot clearly recall one way or the other.