• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Devaka Cooray
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
Bartenders:

Writting to multipule files

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, firstly a little description of my situation! I've started a new job this week, a web design job, and most of the week the corporate site of the company is undergoing change and as a newbe! I get the nice job of changing the code in lots of php files, these files all have the same text in them but need to be changed. So all I'm doing is copying and pasting the new code into these php files, the new code is the same for all these files.
This is REALLY boring so I want to make my job faster, I want to write a program that gets all the files in a directory (php only!) and changes the information in the files. I've done a similar program before but you have to declare the file name first and the output file name:

example:



So what I need to do now is work out how to read in x amount of php files and write the new php code into each file. Can anyone help me?
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How can you identify the part of the file that needs to be replaced - is it a particular string?
 
Gary Goldsmith
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The entire file needs to be changed.
 
Ranch Hand
Posts: 893
Tomcat Server Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why are you solving a PHP-problem with java-code?

You can write your standaard text in one php-file and use a PHP-include in al the other php-pages.

For help on the php-include have a look at

PHP include

This is a more decent solution.
 
This looks like a job for .... legal tender! It says so right in this tiny ad:
Paul Wheaton's 16th Kickstarter: Gardening playing cards for gardeners and homesteaders
https://coderanch.com/t/889615/Paul-Wheaton-Kickstarter-Gardening-playing
reply
    Bookmark Topic Watch Topic
  • New Topic