Jump to content
  • Advertisement
Sign in to follow this  
deadimp

[web] [SOLVED] [php] Unable to read source file, unless using highlight_file()

This topic is 4106 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

On my server, I'm trying to read a source file using PHP, and then outputting the source. However, I can't read the file unless I'm using hightlight_file(), and I want to be able to get a plain-text version of it. I've just looked through my PHP info, but nothing there seems to be set that would prevent me from reading the files. I can read other types, such as text files, but no php source. PHP 5.2.1, XAMPP, WinXP [Edited by - deadimp on June 26, 2007 8:38:08 AM]

Share this post


Link to post
Share on other sites
Advertisement
Strange. File functions, such as file_get_contents or fpassthru, should not care about what the opened file is. Are you using include or require ? If so, I would recommend you don't, as PHP is forced to read through these to search for interpretable PHP source (unless, of course, you actually need the PHP source in the file to be interpreted).

Share this post


Link to post
Share on other sites
I've been using the basic file I/O functions, such as file_get_contents, fopen, file() [with implode()], and a few others, but I'm unable to actually get into the file. I'm not using include() or require(), though.

The snippet o' code:
header("Content-type: text");
if (!$file || is_dir($file)) die('Invalid');
echo implode("",file($file));
return;

This is placed in the overall script, not a function.

EDIT: Aw, dammit. I forgot to look in the source of the file. Turns up, it was reading the file correctly, but my Content-type header isn't correct, I guess, and Firefox's DOM is hiding the PHP tags from me.

EDIT: Had to change it to 'text/plain'.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!