3 ms·
Now granted, I haven’t worked with PHP in one heck of a long time (although that’s purely due to lack of opportunity… I get the warm fuzzies with v7+), but does
by rekabis 9mo ago
Now granted, I haven’t worked with PHP in one heck of a long time (although that’s purely due to lack of opportunity… I get the warm fuzzies with v7+), but doesn’t bad stuff randomly happen if `<?php` isn’t at the very beginning of the first line?
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.
- rafark 8mo agoCorrect. 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