Re: Feature Proposal: Allow letter decrementing

From: Date: Thu, 18 Jul 2013 14:33:40 +0000
Subject: Re: Feature Proposal: Allow letter decrementing
References: 1  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
On Thu, 2013-07-18 at 07:46 -0600, Chris London wrote:
> 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.

Oviously this documented in
http://de2.php.net/manual/en/language.operators.increment.php
;-)

> My question is, why specifically doesn't it?
> 
> It seems logical that if we support increment we should support decrement.

++$string; will always succeed. But what should $s = 'a'; --$s; result
in?

johannes




Thread (22 messages)

« previous php.internals (#68162) next »