How to change one same line of php code that resides in 100 different folders?

I wish to shift a line inside a singular php record (ex: ABCDEFG to 123456). How to do so if we wish to shift a same line though reside in, say, 100 opposite folders but goes to any as well as singular file/folder? Thanks. TA.

One thought on “How to change one same line of php code that resides in 100 different folders?

  1. You could open the file with fopen and try to stream the file to a string variable and then do a str_replace function call. Then you would just use fwrite to overwrite the contents of the file with the modified string.

    To hit all the files and folders just use cwdir to get the current highest level directory then run a dir command and create a loop that recursively visits every folder looking for the php files you want to modify and run the string replace operation on each. Put that into a function to simplify this for yourself.

    Ok so that is the easy way to do it for now. but it is still a huge pain in the ass. What you should really be focusing on is the design and code repetition issues with your code. You shouldn’t have the same thing repeated in multiple places. Instead put the code/html snippet into one file then call an include or require from the files you want to use them in. Place the include where you want this to take effect. Then if you have to change anything in the future you just go to that one file and edit it. The change then goes into effect in all the files.

    Look up coupling and cohesion in programming. Create concepts, you will learn a lot there. Also learn recursion, this is a must for any programmer worth his salt.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>