Jump to content

switch duplicates exactly at 4


SuperBlue

Recommended Posts

I have a switch, which i use to alternate between two numbers. But for some reason, a duplicate occurs exactly at the count of 4, and i haven't been able to figure out why.

 

$Count = 1;

switch ($Count) {
    case 1:
        ++$Count;
        break;
    case 2:
        --$Count;
        break;
}

 

Should output:

2
1
2
1
2
...

But for some reason it gives the below instead..

2
1
2
1
1
2
1
...

 

Subsequent output after the error appears completely normal.  :confused:

Link to comment
https://forums.phpfreaks.com/topic/213984-switch-duplicates-exactly-at-4/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.