Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:68183 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 44612 invoked from network); 19 Jul 2013 07:08:56 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Jul 2013 07:08:56 -0000 Authentication-Results: pb1.pair.com smtp.mail=yohgaki@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=yohgaki@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.217.175 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.217.175 mail-lb0-f175.google.com Received: from [209.85.217.175] ([209.85.217.175:57778] helo=mail-lb0-f175.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 74/28-34315-706E8E15 for ; Fri, 19 Jul 2013 03:08:56 -0400 Received: by mail-lb0-f175.google.com with SMTP id r10so3189983lbi.20 for ; Fri, 19 Jul 2013 00:08:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type; bh=VvuO63Z4P6ytfdSlueb9i4TIo9BvqmL3AQXbd2AevKE=; b=vAPuidF8ZS5y1vHVmkgV+zBMNwAL4VTCGQB6VtxkXoGCLqL0dpTEXZaIInD+YNS9Rb T0P3/Y37GVz6xWUJ4tYIORN21fRtxyCkbcZugReY63aTUcuuZ0bWja2o2xnVLlys0t3Y 3eWzLBgc18xs/bEY6YNXOZpNf/xmsL/6imc5olaYksY0UOvvL12q86LVGu39zlYVyemo DmjzY15gvFla71ttpi/saiw2XnJglsZ2yTmAR0sRQe+5fq6fj09UxCrU7cg89FPz5Wz2 vwMOsyAs89EcQ28sKFpwxPS56Ejo4bT0mmNqRNKpicm0ezNFOtQhPfeHaSEH5dWy8Z+X Ghhw== X-Received: by 10.112.219.102 with SMTP id pn6mr6820674lbc.18.1374217731971; Fri, 19 Jul 2013 00:08:51 -0700 (PDT) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.112.4.233 with HTTP; Fri, 19 Jul 2013 00:08:11 -0700 (PDT) In-Reply-To: References: <-6008161650538629327@unknownmsgid> Date: Fri, 19 Jul 2013 16:08:11 +0900 X-Google-Sender-Auth: 7GcelqZLl-ML8Rj2yo3Mx9XoYdY Message-ID: To: Mateusz Kocielski Cc: Xinchen Hui , Chris London , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a11c3ca14c222b104e1d7ff80 Subject: Re: [PHP-DEV] Feature Proposal: Allow letter decrementing From: yohgaki@ohgaki.net (Yasuo Ohgaki) --001a11c3ca14c222b104e1d7ff80 Content-Type: text/plain; charset=ISO-8859-1 Hi, 2013/7/19 Mateusz Kocielski > > see http://www.php.net/manual/en/language.operators.increment.php > > I don't see any explanation for the examples above. Documentation says: > > [...] For example, in PHP and Perl $a = 'Z'; $a++; turns $a into 'AA' [...] > > I'd expect " ZZ" to become " AAA" rather than " AA". I'm not sure if > it's a bug in documentation, in code. Probably nobody can even > distinguish if it's a bug or feature. > You may play with one liner. php -r "\$a = ' ZZ';for (\$i=0; \$i<100000000;\$i++) var_dump(++\$a);" This feature existed when I start using PHP3. Manual says > Note that character variables can be incremented but not decremented and > even so only plain ASCII characters (a-z and A-Z) are supported. Incrementing/decrementing > other character variables has no effect, the original string is unchanged. This behavior is due to the algorithm used for string ++/--. I think it looks at the end of char and tries to increment, but it finds non [a-zA-Z] char and stops operation. Therefore, it cycles over and over. It may seems strange, but I don't see reason to change. Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net --001a11c3ca14c222b104e1d7ff80--