3

Out of interest, why on windows does this produce a warning (and returns false):

range(date('Y'), date('Y') + 5)

Warning: range() [function.range]: step exceeds the specified range

Doesn't happen on the live server, just windows. I've been looking for the bug report but haven't found one. Also, if you run two iterations, only the first one fails.

I can replicate sometimes but not others. ie. If I refresh say 20 times, only 2 or 3 of them will give the warning.

I'm using 5.3.5

Ashley
  • 5,939
  • 9
  • 39
  • 82
  • The default step size is 1. You should check what date('Y') returns before making use of the value, e.g. storing it into a variable so you don't call the function twice even. Then check if you properly configured the timezone on your windows PHP installation, that's just something that *might* be related to your problem. – hakre Jul 20 '11 at 14:25
  • Yea I tried using a variable but it still produces the same. Strange it only happens some times though, my guess too is that it's Windows timezone settings (I have set my by default to Europe/London). – Ashley Jul 20 '11 at 14:51
  • In case it fails, just log the variable content, you should then see. And check for PHP startup errors. If there are some regarding timezone settings, the this could be. If not then timezone should be totally unrelated and a no-issue. – hakre Jul 20 '11 at 17:38

2 Answers2

3

Upgrading to 5.3.6 fixed this. Not sure what the problem was.

Ashley
  • 5,939
  • 9
  • 39
  • 82
  • I'm glad you said that, because I was about to say I couldn't reproduce it. You should mark your answer as correct with the tick icon so the question doesn't hang around in the 'unsanswered questions' list. :-) – Spudley Jul 21 '11 at 09:22
  • Can't until tomorrow but I will :) – Ashley Jul 21 '11 at 09:48
0

I am using PHP 5.3.2 under windows and I can't reproduce the problem. Everything is working fine and as expected. Maybe you have a other problem somewhere else leading to this error.

$a = range(date('Y'), date('Y') + 5);
print_r($a);

this prints:

Array
(
  [0] => 2011
  [1] => 2012
  [2] => 2013
  [3] => 2014
  [4] => 2015
  [5] => 2016
)
Marco
  • 960
  • 2
  • 7
  • 26
  • I can only replicate sometime (see update post). Out of 20 times, 2 or 3 will give an warning – Ashley Jul 20 '11 at 11:50
  • I tried it out exactly 50 times. 50 times everthing was ok. Sorry! Can't help you out... – Marco Jul 20 '11 at 11:59