I talk about code and stuff
What do you do if you need to “comment out” a whole PHP file?
You could prefix every line with //
, wrap the whole thing in a /* */
block, wrap it in if (false) { }
, but none of those are very elegant. In most IDEs, if you select the whole file CMD+A and use a hotkey to comment it CMD+/, it’ll actually wrap it in HTML comments <!-- -->
because the code outside the PHP tags is typically HTML.
There’s a little technique I spotted Nuno Maduro using in his talk at Laracon US 2024 - it feels obvious in hindsight - just add an early return immediately after the opening PHP tag - then nothing after it will be loaded at all:
<?php return;
none_of_this_code_will_execute();