Edit more than 1 php file at a time?

Discussion in 'PHP' started by clarkhaddock, Dec 4, 2008.

  1. #1
    Is there a way to Edit more than 1 php file at a time? I have about 25 files that i want to edit the same line of code on each of those files. I really do not know very much php so it would have to be something very simple or possibly some type of software. any ideas or suggestions?
     
    clarkhaddock, Dec 4, 2008 IP
  2. clarkhaddock

    clarkhaddock Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    thank you!!
     
    clarkhaddock, Dec 4, 2008 IP
  3. blackthought286

    blackthought286 Well-Known Member

    Messages:
    334
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #3
    I don't know of a program that will do that off hand but in the future you might want to go through those files and where that line is at place a function and an include command on top of it. For example

    
    
    include("example.php");
    
    //the function with the line
    func();
    
    
    PHP:
    That way you will never have to go to each page ever again. You just have to change the line in that one function. Look at also require() and require_once().
     
    blackthought286, Dec 4, 2008 IP
  4. atlantaazfinest

    atlantaazfinest Peon

    Messages:
    389
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #4
    atlantaazfinest, Dec 5, 2008 IP
  5. sandstorm140

    sandstorm140 Peon

    Messages:
    80
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    For better understanding of the include function, you could basically use it for... lets say, a nav menu (nav.php). Setup a basic template that you will not need to alter on 25 pages, and inside the html include the nav page with include('nav.php').
    Then any changes you need made to the nav page, all other 25 pages are automatically changed since the include function pulls in the same nav.php each time the page is loaded.
     
    sandstorm140, Dec 5, 2008 IP
  6. bt09acd

    bt09acd Well-Known Member

    Messages:
    40
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    111
    #6
    1. put all your php files in the same folder;
    2. download pspad: http://www.pspad.com/en/download.php;
    3. open pspad and Projects->Create project from directory
    4. search->Search/Replace in files...

    But, as the others said, it's much easier to use include 'filename.ext'
     
    bt09acd, Dec 5, 2008 IP
  7. RRWH

    RRWH Active Member

    Messages:
    821
    Likes Received:
    49
    Best Answers:
    0
    Trophy Points:
    70
    #7
    write a simple shell/sed script. Loop thru all the files and apply the edit using sed

    This is a pretty simple shell script and the easiest way to work with what you currently have.


    Here is a simple shell script that will do what you need

    
    
    #!/bin/bash
    
    for ZZZ in `grep asdf *|cut -f1 -d:`
    do
       sed -i ' s/asdf/fdsa/g' $ZZZ
    done
    
    
    Code (markup):
    the above example will find all files with asdf in them within the current directory, then replace it with fdsa

    4 line shell script is the easiest way to do this trivial task.
     
    RRWH, Dec 7, 2008 IP
  8. lordofthelake

    lordofthelake Peon

    Messages:
    70
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #8
    I use Notepad++ with "Find in files" function and then "Replace in all opened files".
     
    lordofthelake, Dec 7, 2008 IP
  9. kmap

    kmap Well-Known Member

    Messages:
    2,215
    Likes Received:
    29
    Best Answers:
    2
    Trophy Points:
    135
    #9
    i use PSPAD this is best tool i have ever seen

    It also works great for many other languages

    Regards

    Alex
     
    kmap, Dec 7, 2008 IP
  10. firman01

    firman01 Well-Known Member

    Messages:
    155
    Likes Received:
    2
    Best Answers:
    1
    Trophy Points:
    165
    #10
    in linux, go to the directory where your files are
    
    repalce 'oldstring' 'newstring' -- *.php
    
    Code (markup):
     
    firman01, Dec 7, 2008 IP
  11. haradeep

    haradeep Well-Known Member

    Messages:
    231
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    130
    #11
    Use notepad++
    I edit more than 20 page at a time
     
    haradeep, Dec 8, 2008 IP
  12. octalsystems

    octalsystems Well-Known Member

    Messages:
    352
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    135
    Digital Goods:
    1
    #12
    i uses the Dreamweaver
    u can search in any given folder for a phrase and then u can replace
     
    octalsystems, Dec 8, 2008 IP
  13. firman01

    firman01 Well-Known Member

    Messages:
    155
    Likes Received:
    2
    Best Answers:
    1
    Trophy Points:
    165
    #13
    like octalsystems said, but if dreamweaver is too expensive for you, you can use UltraEdit (for windows user)
     
    firman01, Dec 9, 2008 IP