SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: show php code

  1. #1
    SitePoint Zealot
    Join Date
    Dec 2008
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    show php code

    hi there

    I have a directory with php example files, and I've generated the list of the files as a href.
    How can I display the content of any file I've click. I was thinking to read the file using fgets().

    is that possible? or how to do that?

  2. #2
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes. You will need to have the php script serve the proper mime headers depending on the type of file. You can do this with the header() function. readfile() would be easier than fgets in any case. But if you just want the browser to display the contents as you would see if you opened the file in say, notepad, then just serve all files as content-type: text/plain

  3. #3
    SitePoint Evangelist
    Join Date
    Jun 2006
    Location
    Wigan, Lancashire. UK
    Posts
    523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dole.doug View Post
    How can I display the content of any file I've click. I was thinking to read the file using fgets().
    highlight_file()
    ---
    Development Projects:
    PHPExcel
    PHPPowerPoint

  4. #4
    SitePoint Wizard silver trophybronze trophy Stormrider's Avatar
    Join Date
    Sep 2006
    Location
    Nottingham, UK
    Posts
    3,133
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Or just name it .phps


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •