Jump to content

Value check resets value


pthes

Recommended Posts

I have come across the strangest error in one of my sites today. I checking to see what hour of the day it is and then use it as the default value of a dropdown box. The problem is that if the hour is "08" or "09" the value gets set to "00".

 

I created simple code to test.

 

 

<?php  $val = 01; ?>

<?php if ($val == 01) { echo $val."  what is this!!";} else {echo "should be 1";} ?>

 

<?php  $val = 02; ?>

<?php if ($val == 02) { echo $val."  what is this!!";} else {echo "should be 2";} ?>

 

 

<?php  $val = 08; ?>

<?php if ($val == 08){ echo $val."  what is this!!";} else {echo "should be 8";} ?>

 

<?php  $val = 09; ?>

<?php if ($val == 09) { echo $val."  what is this!!";} else {echo "should be 9";} ?>

 

 

This is what I get

 

1 what is this!! 2 what is this!! 0 what is this!! 0 what is this!!

 

It looks like when $val == 08 is executed it sets $val to 0 !!

 

I'm using PHP 5

 

If anyone has seen this before please let me know what's going on.

 

Thanks.

 

Link to comment
https://forums.phpfreaks.com/topic/47464-value-check-resets-value/
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.