LiamProductions Posted June 16, 2007 Share Posted June 16, 2007 Hey. I started to learn PHP coding. And i was wondering with the fopen syntax can it only read and open .txt files? i've not tryed a .txt file yet. but i've tryed a .php extension and nothing happens. Please reply if you can. Thanks, LiamProductions.com Link to comment https://forums.phpfreaks.com/topic/55871-help-please/ Share on other sites More sharing options...
The Little Guy Posted June 16, 2007 Share Posted June 16, 2007 it should be able to read anything you give it. <?php $filename = "location/of/the/file.php"; $handle = fopen($filename, "r"); $location = $filename; if(file_exists($location)){ while (!feof($handle)){ $text = fgets($handle); echo $text; ?> Link to comment https://forums.phpfreaks.com/topic/55871-help-please/#findComment-276010 Share on other sites More sharing options...
LiamProductions Posted June 16, 2007 Author Share Posted June 16, 2007 On the W3Schools tutorial. Heres the script it says to use when reading a file. <html> <body> <?php $file=fopen("index.php","r"); ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/55871-help-please/#findComment-276012 Share on other sites More sharing options...
The Little Guy Posted June 16, 2007 Share Posted June 16, 2007 that reads the file, it doesn't do anything with it, except save it in memory for later use. Link to comment https://forums.phpfreaks.com/topic/55871-help-please/#findComment-276015 Share on other sites More sharing options...
LiamProductions Posted June 16, 2007 Author Share Posted June 16, 2007 Argh. So that code does'nt do anything basicly? Link to comment https://forums.phpfreaks.com/topic/55871-help-please/#findComment-276016 Share on other sites More sharing options...
The Little Guy Posted June 16, 2007 Share Posted June 16, 2007 not at the moment, give my code a try, it should read and output the file content Link to comment https://forums.phpfreaks.com/topic/55871-help-please/#findComment-276017 Share on other sites More sharing options...
LiamProductions Posted June 16, 2007 Author Share Posted June 16, 2007 Ok, i will do Link to comment https://forums.phpfreaks.com/topic/55871-help-please/#findComment-276018 Share on other sites More sharing options...
LiamProductions Posted June 16, 2007 Author Share Posted June 16, 2007 Nothing happens still. Link to comment https://forums.phpfreaks.com/topic/55871-help-please/#findComment-276021 Share on other sites More sharing options...
The Little Guy Posted June 16, 2007 Share Posted June 16, 2007 did you replace this line: location/of/the/file.php with where ever you saved the file? Link to comment https://forums.phpfreaks.com/topic/55871-help-please/#findComment-276024 Share on other sites More sharing options...
LiamProductions Posted June 16, 2007 Author Share Posted June 16, 2007 yes. Link to comment https://forums.phpfreaks.com/topic/55871-help-please/#findComment-276042 Share on other sites More sharing options...
AndyB Posted June 16, 2007 Share Posted June 16, 2007 Please post the actual code you have at present. Link to comment https://forums.phpfreaks.com/topic/55871-help-please/#findComment-276055 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.