php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #10734 Strange conversion string->numbers
Submitted: 2001-05-08 11:26 UTC Modified: 2001-05-10 08:58 UTC
From: konrad at interdata dot net dot pl Assigned:
Status: Closed Package: *General Issues
PHP Version: 4.0.5 OS: Linux 2.2 glibc-2.2.1
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: konrad at interdata dot net dot pl
New email:
PHP Version: OS:

 

 [2001-05-08 11:26 UTC] konrad at interdata dot net dot pl
Here is a simple code

<?
header("content-type: text/plain");

$num = -5;
echo "$num\n";
$num++;
echo "$num\n";
$num--;
echo "$num\n";
echo "----------\n";

$num = "-5";
echo "$num\n";
$num++;
echo "$num\n";
$num--;
echo "$num\n";
?>

And here results

-5
-4
-5
----------
-5
-6 <-- ?????????????????
-7

It looks like "++" operator do not work properly on variables enclosed in double-quotes.
Other operators (ie $num = $num +1) woks properly.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-05-08 11:44 UTC] hholzgra@php.net
AFAIR this is some strange magic borrowed from perl

the deeper sense in this is that you can use it
to increment/decrement the numerical part of
serial numbers and such

IMHO this is more confusing then helpfull and
should be nuked 
 [2001-05-10 08:58 UTC] zeev@php.net
Fixed in the CVS.  Thanks for the report!
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 28 10:01:29 2024 UTC