file_get_contents doesn't read file from variable
Posted: Sun Oct 18, 2009 4:00 am
Hi,
I'm facing a really strange problem. I have a file named 'map' with the following contents:
1;'pag1.html'
2;'pag2.html'
3;'pag3.html'
Then I try to read it with the following php code:
My expectation was to see the content of the file pag2.html but php says that the file doesn't exist. I tried this by:
Much more strange is that if I use the following code:
instead of the variable $filename I have no problem to see the file contents.
So why I can see the file pag2.html contents if I use file name string but the file doesn't exist if I use the variable $filename ?
Many thank in advance.
I'm facing a really strange problem. I have a file named 'map' with the following contents:
1;'pag1.html'
2;'pag2.html'
3;'pag3.html'
Then I try to read it with the following php code:
Code: Select all
$lines = file('map');
foreach ($lines as $line_num => $line) {
list($num,$filename)=explode(";",$line);
if ($num==2) {
echo file_get_contents($filename);
break;
}
}Code: Select all
file_exists ($filename)Code: Select all
echo file_get_contents('pag2.html')So why I can see the file pag2.html contents if I use file name string but the file doesn't exist if I use the variable $filename ?
Many thank in advance.