My friend shared some code with me today that wasn't working for him. He
was incrementing letters like this:

$letter = 'A';
echo ++$letter; // Output: B

He was then trying to decrement letters like this:

$letter = 'B';
echo --$letter; // Output: B

He was really confused why his code wasn't working.  Obviously the answer
is, PHP doesn't support decrementing letters.

My question is, why specifically doesn't it?

It seems logical that if we support increment we should support decrement.

My proposal:

1) Support decrementing letters
- or -
2) Throw a notice explaining that decrementing is not supported so
developers quickly know they can't do that

One hiccup. I imagine maybe the reason we don't support decrementing is
because what would happen if you tried to decrement 'A'. In that case I
would suggest either returning NULL or throwing a notice.

Thanks for the input

Chris London

Reply via email to