torkell: (Default)
[personal profile] torkell

A collection of mini-rants today, from a couple of hours spent hacking together a bit of PHP:

  1. Which numpty decided that the default behaviour of a switch statement should be to fall through. It's almost never what you want!
  2. In the same theme, which numpty decided to make assignment and equality use different operators, to make assignment single-equals, and to not have any kind of warning if you use single-equals in an if statement.
  3. Why does PHP not have a usable variable type for dates? Even classic VB has one!

Date: 2011-03-26 01:07 pm (UTC)
From: [identity profile] crschmidt.livejournal.com
... In what world are the first two different than... well, everything?

Those behaviors are the only ones that seem likely to me. Doing anything else (especially in PHP, which doesn't really have a compile stage at which to issue sane warnings) would make me react the reverse of how you did: "What do you *mean* switch doesn't fall through?"

Aren't they both just carryovers from C?

Date: 2011-03-26 11:26 pm (UTC)
From: [identity profile] crschmidt.livejournal.com
The last thing, I feel you on, though I've never had any experience with a language that has strong date support built in. Python is closest, but calling datetime objects reasonable would be a stretch, in my opinion. PHP isn't any better or worse than most in that regard: everything pretty much sucks.

I guess I've never worked in a language that wasn't derived from C syntax in that way, so again, I would find it surprising that something like PHP -- which clearly shows its roots as a C-style syntax -- didn't behave like C did. It can be frustrating switching from another paradigm, certainly, but I don't think PHP is to blame there, just happens to be where you got bit :)

January 2026

S M T W T F S
     123
45678910
11121314151617
18192021222324
25262728293031

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated May. 9th, 2026 09:18 am
Powered by Dreamwidth Studios