Re: Re: [VOTE] [RFC] Alphanumeric Decrement
Hi Tjerk,
On Tue, Jan 28, 2014 at 10:39 AM, Tjerk Meesters
<[email protected]>wrote:
> I still have an RFC lying around that suggests this, together with some
> other changes to how increment / decrement works. Perhaps we could flesh
> this out further?
>
> https://wiki.php.net/rfc/normalize_inc_dec
>
The following behaviour is proposed:
// booleans
$a = false; ++$a; // bool(true)
$a = true; --$a; // bool(false)
// null values
$a = null; --$a; // null
$a = null; ++$a; // null
// empty strings
$a = ''; ++$a; // int(1)
// non-numeric strings
$a = '12d9';
++$a; // string(4) "12e0" + Notice: String increment is deprecated, use
str_inc() instead in php shell code on line 1
++$a; // float(13)
+1 especially boolean++/--.
It's great for flip flop. I guess most users use int++ and int%2 for flip
flop currently.
Existing scripts using ++/-- against bool would be a bug most likely.
Other proposal sounds reasonable to me, too.
Regards,
--
Yasuo Ohgaki
[email protected]
Thread (19 messages)