Edit file with php

Discussion in 'PHP' started by MajHate, Apr 20, 2009.

  1. #1
    Hello,

    I figured out how to create a file with php. However I need to edit the new file that I created. The file is a php file, i just want to put some html and some php in it. Does anyone know how to edit this file with using php?

    Thank You,
    Jason
     
    MajHate, Apr 20, 2009 IP
  2. life31

    life31 Active Member

    Messages:
    1,024
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    78
    #2
    Just open it with notepad and add whatevery you intend to add. And then save. Its that easy.

    Hope I am preety clear.
     
    life31, Apr 20, 2009 IP
  3. darren884

    darren884 Peon

    Messages:
    37
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Use the php file commands.
     
    darren884, Apr 20, 2009 IP
  4. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #4
    
    <?php
    
    $fp=fopen("test.php","r");
    $content=fread($fp,8192);
    ?>
    <textarea rows="30" cols="100" value="<?php echo $content; ?>"><?php echo $content; ?></textarea>
    
    PHP:
    The above code will open the file "test.php", read it into the $content-variable, and post that variable as the value of a text-field. You can then add to that so when you submit the form with the text-field, you rewrite the file in question, using the value from the textfield.
     
    PoPSiCLe, Apr 20, 2009 IP
  5. hnaghy

    hnaghy Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    A php file can be opened with any standard text file program. For example, even microsoft notepad will open and save to PHP files. Providing it has no actual PHP code/programming involved in the file, you could actually rename it as a HTML file and edit it the same way.

    As for visually editing the HTML elements of a PHP file, dreamweaver is probably one of the better tools to use however there are many programs which will do this. You will need to search for "WYSIWYG" editors.
     
    hnaghy, Apr 21, 2009 IP