very strange error
Posted: Fri Jun 24, 2005 11:31 pm
I have a recursive function that looks something like this:
<?php
...recursive function... where value in first line is read, then incremented.
$data=file("data.txt");
print "value is: ".$data[0];
?>
The last line is for testing. There is nothing after that line, no php or html code. The very last line in the file is the ?> .
The strange thing is, I get a value, for example, 10, print out for the last line. So supposedly if I go look at the file, I should find a 10 in the first line. But this is not so. I take a look at it and it is 18.
If the value printed is n, then the value that is in the file is n + 8.
I don't understand how this is possible. There is nothing there after the print... except for the ?>. Nothing should be able to change this value in the file. But when I download the file after running this, it's always n + 8.
I saved another php file with just:
<?php
$data=file("data.txt");
print "value is: ".$data[0];
?>
in it, then ran it, and this correctly reads the value as n + 8. This increment isn't supposed to happen. I have no idea where it's coming from. Surprisingly, the function works absolutely perfectly as expected outside of this peculiar increment that seems to come from nowhere.
<?php
...recursive function... where value in first line is read, then incremented.
$data=file("data.txt");
print "value is: ".$data[0];
?>
The last line is for testing. There is nothing after that line, no php or html code. The very last line in the file is the ?> .
The strange thing is, I get a value, for example, 10, print out for the last line. So supposedly if I go look at the file, I should find a 10 in the first line. But this is not so. I take a look at it and it is 18.
If the value printed is n, then the value that is in the file is n + 8.
I don't understand how this is possible. There is nothing there after the print... except for the ?>. Nothing should be able to change this value in the file. But when I download the file after running this, it's always n + 8.
I saved another php file with just:
<?php
$data=file("data.txt");
print "value is: ".$data[0];
?>
in it, then ran it, and this correctly reads the value as n + 8. This increment isn't supposed to happen. I have no idea where it's coming from. Surprisingly, the function works absolutely perfectly as expected outside of this peculiar increment that seems to come from nowhere.