rockinaway Posted September 9, 2007 Share Posted September 9, 2007 I need to open a file and then echo the contents into a text area. I tried file_get_contents(), but it doesn't work, it isn't recognised as a function.. Any other way of doing this? Quote Link to comment https://forums.phpfreaks.com/topic/68572-open-file-and-get-contents/ Share on other sites More sharing options...
wildteen88 Posted September 9, 2007 Share Posted September 9, 2007 file_get_contents does exist! What version of PHP do you have? file_get_contents is available from PHP4.3.x. If you have a version earlier than this version you're better of upgrading PHP. Quote Link to comment https://forums.phpfreaks.com/topic/68572-open-file-and-get-contents/#findComment-344686 Share on other sites More sharing options...
rockinaway Posted September 9, 2007 Author Share Posted September 9, 2007 I use the latest, in my editor it doesn't change colour to show it is a function... I am using $file = file_get_contents('filename') Quote Link to comment https://forums.phpfreaks.com/topic/68572-open-file-and-get-contents/#findComment-344687 Share on other sites More sharing options...
pranav_kavi Posted September 9, 2007 Share Posted September 9, 2007 did u try executing it???it may work... Quote Link to comment https://forums.phpfreaks.com/topic/68572-open-file-and-get-contents/#findComment-344688 Share on other sites More sharing options...
wildteen88 Posted September 9, 2007 Share Posted September 9, 2007 What editor are you using? Have you tried echo'ing $file. Just because your editor doesn't highlight the function doesn't mean it exists. I guess you are using Dreamweaver or something. Dreamweaver is not a proper PHP editor so dont trust any feed back it gives. You are always better of running your code through PHP to see if something works or not. Quote Link to comment https://forums.phpfreaks.com/topic/68572-open-file-and-get-contents/#findComment-344689 Share on other sites More sharing options...
rockinaway Posted September 9, 2007 Author Share Posted September 9, 2007 Ok.. it is returning content, but not the full file. It is returning half the file and that too from line 174.. so literally half way down.. Quote Link to comment https://forums.phpfreaks.com/topic/68572-open-file-and-get-contents/#findComment-344690 Share on other sites More sharing options...
rockinaway Posted September 9, 2007 Author Share Posted September 9, 2007 Also how can I format the contents so that where there are linebreaks, it returns line breaks etc? Quote Link to comment https://forums.phpfreaks.com/topic/68572-open-file-and-get-contents/#findComment-344692 Share on other sites More sharing options...
Ninjakreborn Posted September 9, 2007 Share Posted September 9, 2007 I don't really have time to look it up now. However there are 2 really good functions for this inside the codeignitor framework. 2-3 of the BEST functions I have ever found. Very simple to use, and quick. It's under file helpers, but they are amazing. I carry that set around everywhere now. Quote Link to comment https://forums.phpfreaks.com/topic/68572-open-file-and-get-contents/#findComment-344769 Share on other sites More sharing options...
AndyB Posted September 9, 2007 Share Posted September 9, 2007 Ok.. it is returning content, but not the full file. It is returning half the file and that too from line 174.. so literally half way down.. How are you displaying that? From within some editor or other, or within working php code? Quote Link to comment https://forums.phpfreaks.com/topic/68572-open-file-and-get-contents/#findComment-344770 Share on other sites More sharing options...
darkfreaks Posted September 9, 2007 Share Posted September 9, 2007 dreamweaver absolutely sucks with PHP code get Jedit Quote Link to comment https://forums.phpfreaks.com/topic/68572-open-file-and-get-contents/#findComment-344771 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.