- Feature Articles
- CodeSOD
- Error'd
-
Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
No, it doesn't. It has an alternative syntax for blocks. See e.g. https://www.php.net/manual/en/control-structures.alternative-syntax.php
It's quite clearly an alternative syntax, both in the URL and the actual page of docs.
Hmm. Apparently, the use of "alternate" to mean "alternative" is a strong Americanism. I suppose I could be persuaded to forgive you... ;)
Admin
Looks like the colon syntax is meant for when you mix your PHP with HTML, just to make it easier to read.
Also note that you have to use
elseifinstead ofelse ifwhen using colon syntax.Admin
We're getting them in place of October-December, so it's not like we're missing summer or anything. Honestly just skipping the slow descent through autumn and getting straight into the thick of winter might not be a bad thing. Only downside I see is Christmas... no, not skipping it: Russian Christmas is in January, so this way you have to go through that rigmarole four times in a row! (NB I have not checked whether those months are actually Russian or another language with the Cyrillic alphabet.)
Admin
Method get_the_date() is not a Core PHP Method. It is from "WordPress Developers Resources" (url: ...//developer.wordpress.org/reference/functions/get_the_date/).
Admittedly WordPress is a PHP Application but, despite the pervasive meme that "PHP is bad", it is not PHP's fault. For your convenience (and it should have been referenced in the Article to give the Judgement some credence), The Method is:
function get_the_date( $format = '', $post = null ) { $post = get_post( $post );
}
The "warthog" in me could not find the will to explore further. I.e. track down the other "methods" invoked.
Admin
They effectively do look like Russian but in feminine form. Don't know if it's another WTF or a country dependent thing though 🤔
Admin
Heretic. Blasphemer. Autumn is infinitely superior to all other seasons. None of the other seasons have Halloween, for example. Or Thanksgiving. Okay, I'm clearly American, so you've tuned out already. Bye.
Admin
They are in the genitive case, which is proper when used within a date. However in that case, they should not be capitalized, which the array values seemed to be. So still one more oddity.
Anyway, the entire thing looks like new code that the next intern will get to debug next Winter.
Also, if you google 'php convert date', it only takes a few seconds to find at least one example which suggest a regex is the best way to do this, instead of, you know, using internal functions already present to scan dates. Because clearly library date functions have to be slower then making your own. One can never trust libraries.
Admin
Maybe the writer is among the oldest of Old Calendarists, and rejects the 12-month innovation of the Julian reforms
Admin
Autumn is the best. It's not too hot, it's not too cold (although it gets a little messy because all the leaves come off the trees. In my corner of the world halloween happens in spring. Spring kind of sucks. The weather is really stormy, the stores have put out all the obnoxious Christmas adverts even though it's like 4 months away, and if you don't put up a no halloween sign, when it comes to october you get an endless stream of door knockers ignoring your no soliciting sign.
Admin
The alternative syntax is what really gives PHP its power as a templating language, removing the need for a bunch of string munging when all you want to do is pop some variables into some markup. I made a good living in my younger days building bespoke blog engines using that syntax and will happily still sing its praises.
Admin
I've used the alternative syntax for blocks for decades :)
It allows you to not have to 'echo' out the HTML code, you just put the fancy blocks in and then put regular HTML in-between.
Admin
PHP got a proper date/time library 20 years ago and it still holds up today. But, yes it's physically possible to ignore it and write back custom code, so PHP clearly sucks.
Addendum 2026-06-03 06:27: *bad
Admin
Is all of this because someone thought that the number "01" is different from "1" and that the month lookup would fail? I don't do much PHP, does it just need a cast to int?
Admin
The ARGHHH!!! for me is those functions should be named date_get() date_explode() date_foo() etc.
Admin
The while inside the if is not a WTF, and makes sense in this case. The if provides alternative content in case there are no posts to be listed. The block of code doesn't show the "else", but it should be there. It's like:
if (have posts) { while (have_posts()) { // list the posts } } else { print "there are no posts to show" }
Without the else, in case there are no posts, it will just display nothing instead of a meaningful message.
Admin
Also, the "alternative" syntax (endif, endwhile, endfor, etc) is useful when you have several closing tags one after the other. Helps you know what is closing where.
Instead of:
} }
you'd have:
endfor; endif;
But yeah, nothing a modern IDE wouldn't help you with.
Admin
The code style that I enforce on my PHP codebase is to use curly braces only if they are opened and closed within the same PHP code block (<? ?>). If you open a conditional/loop in one block but close it in another, use the alternative syntax. This keeps things nice and concise in files that are dedicated code blocks, but makes it much easier to find the start and end of a loop in view files, where the braces might otherwise be easily lost in all the HTML.
I have also mandated the use, wherever possible, of typed parameters and returns, variables are to be declared before use, and the standard library is to be used whenever a function exists. Stuff like that - plus basic code quality - keeps at bay the horrors so often found in PHP codebases.