tags:

views:

80

answers:

3

Is there any reason why the fread() function wouldn't work (no errors show up) when reading from a .php file over a .txt file?

code

$file = fopen("db.php","rw");
$data = fgets($file, filesize("db.php"));
echo($data);
fclose($file);
die();
+2  A: 

Is there any reason why the fread() function wouldn't work (no errors show up) when reading from a .php file over a .txt file?

No, not if you're addressing them the same way (same protocol / method / location). They're all just plain data to fread().

Pekka
+2  A: 

Are the permissions the same for the .php file and the .txt file? I know that seems obvious but sometimes it's the little things that get by us.

Austin
http://cl.ly/Ags Yep, they are the same but this should be fine anyway?
tarnfeld
That's interesting. So what exactly happens? When you use fread() to open the PHP file, the stream is empty? But it works for the TXT file?
Austin
Yeah which is why i'm so confused :/
tarnfeld
Try pastebin'ing all of your code I suppose.
Austin
It works with a .txt file if its not starting with <?php .. ?>
tarnfeld
What about a PHP file that doesn't have <?php .. ?> in it?
Austin
@tarnfeld you're not fetching a file using `http://`, right? Because that would get interpreted if it's a PHP file.
Pekka
Ignore my most recent comment, that isnt true, no its just a file in the same directory.
tarnfeld
@tarnfeld strange. Can you show an example path?
Pekka
what you mean, i just put in "db.php" into fopen
tarnfeld
Added code.....
tarnfeld
A: 

Answered in comments.

tarnfeld