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 Quote 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; ?> Quote 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> Quote 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. Quote 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? Quote 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 Quote 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 Quote 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. Quote 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? Quote 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. Quote 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. Quote Link to comment https://forums.phpfreaks.com/topic/55871-help-please/#findComment-276055 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.