P3t3r Posted January 7, 2008 Share Posted January 7, 2008 I'm not sure I picked the right forum for this question: if I want to replace a string by another string in all my .php files, how do I do this best? E.g. replacing all include( by require( or so. In all files + subdirs, without me having to list the files one by one of course. How do I do this best? A program or a shell command (sed didn't do subdirs for me) or both. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/84879-editing-many-php-files-at-once/ Share on other sites More sharing options...
Daniel0 Posted January 7, 2008 Share Posted January 7, 2008 Use functions like preg_replace() or str_replace(). Quote Link to comment https://forums.phpfreaks.com/topic/84879-editing-many-php-files-at-once/#findComment-432705 Share on other sites More sharing options...
trq Posted January 7, 2008 Share Posted January 7, 2008 Or sed if your on Linux. sed -i -e 's/include/require/g' *php Quote Link to comment https://forums.phpfreaks.com/topic/84879-editing-many-php-files-at-once/#findComment-432743 Share on other sites More sharing options...
chronister Posted January 7, 2008 Share Posted January 7, 2008 if you use dreamweaver you can do sitewide replaces there. Otherwise, grab a program like windows grep for windows obviously and it will search through loads of pages quickly and find what your looking for allowing you to change pretty quickly. Quote Link to comment https://forums.phpfreaks.com/topic/84879-editing-many-php-files-at-once/#findComment-432782 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.