zimbabweo Posted March 11, 2013 Share Posted March 11, 2013 I can't figure out how to combine readfile() with <pre> tags so that the \n linebreaks in my text file are displayed properly. // works but doesn't print line breaksecho readfile("filename.txt"); // doesn't work -- parse error echo "<pre>readfile("filename.txt")</pre>"; // doesn't work -- parse errorecho "<pre>{readfile("filename.txt")}</pre>\n"; Any tips to solve this? Quote Link to comment https://forums.phpfreaks.com/topic/275478-tags-with-readfile/ Share on other sites More sharing options...
Barand Posted March 11, 2013 Share Posted March 11, 2013 (edited) echo '<pre>'; readfile('filename.txt'); echo '</pre>'; or echo nl2br(file_get_contents('filename.txt')); Edited March 11, 2013 by Barand Quote Link to comment https://forums.phpfreaks.com/topic/275478-tags-with-readfile/#findComment-1417882 Share on other sites More sharing options...
zimbabweo Posted March 11, 2013 Author Share Posted March 11, 2013 Barand, that works perfectly!! Many thanks. Quote Link to comment https://forums.phpfreaks.com/topic/275478-tags-with-readfile/#findComment-1417883 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.