How to read in PHP a .php file?

Discussion in 'PHP' started by dare2k, Jan 14, 2011.

  1. #1
    How to read in PHP a .php file without compiling it, so I can edit it and and save it in a browser?

    I need to put it out on an editable textbox.
     
    dare2k, Jan 14, 2011 IP
  2. rainborick

    rainborick Well-Known Member

    Messages:
    424
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    120
    #2
    Use fopen() an fread() to read the file and then you can display the contents as text.
     
    rainborick, Jan 14, 2011 IP
  3. IAreOwn

    IAreOwn Active Member

    Messages:
    46
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    95
    #3
    open it with notepad++ , or any text editor..
     
    IAreOwn, Jan 14, 2011 IP
  4. dare2k

    dare2k Peon

    Messages:
    80
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    i've tried that.
    It works well for text files but if a recognizable command gets in it doesn't display anything.
     
    dare2k, Jan 14, 2011 IP
  5. ssmm987

    ssmm987 Member

    Messages:
    180
    Likes Received:
    4
    Best Answers:
    3
    Trophy Points:
    43
    #5
    
    $fp=fopen("test.php","r");
    $contents=fread($fp",filesize("test.php"));
    fclose($fp);
    
    PHP:
     
    ssmm987, Jan 14, 2011 IP
  6. dare2k

    dare2k Peon

    Messages:
    80
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I want to create an online editor for a specific php file
     
    dare2k, Jan 14, 2011 IP
  7. dare2k

    dare2k Peon

    Messages:
    80
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    ssmm987 the code that you written returns a lot of data that are not in the file
     
    dare2k, Jan 14, 2011 IP
  8. ssmm987

    ssmm987 Member

    Messages:
    180
    Likes Received:
    4
    Best Answers:
    3
    Trophy Points:
    43
    #8
    Such as? It works fine for me!
     
    ssmm987, Jan 14, 2011 IP
  9. IAreOwn

    IAreOwn Active Member

    Messages:
    46
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    95
    #9
    ssmm987 code should work, what do you mean data that are not in the file,,,
    
    <?php
    $fp=fopen("test.php","r");
    $contents=fread($fp,filesize("test.php"));
    fclose($fp);
    ?>
    
    <textarea rows="30" cols="50"><?php echo $contents;?></textarea>
    
    PHP:
     
    IAreOwn, Jan 14, 2011 IP
  10. dare2k

    dare2k Peon

    Messages:
    80
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    a lot of tables with specifications (like align, etc.) but i don't have any tables in my php
     
    dare2k, Jan 14, 2011 IP
  11. dare2k

    dare2k Peon

    Messages:
    80
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    thanks!!!
    don't know why but i created another php with the same code and now it works.
     
    dare2k, Jan 14, 2011 IP
  12. Rudolf Bodocsi

    Rudolf Bodocsi Peon

    Messages:
    69
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Rudolf Bodocsi, Jan 14, 2011 IP