need a find/replace command to fix my require_once

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I was reading this: http://pear.php.net/manual/en/standards.including.php
and it states: 

	"Note: include_once and require_once are statements, not functions.
Parentheses should not surround the subject filename." 

I never knew that. I've always (wrongly) used:
 
     require_once('/path/to/my/file');
 
Anyone have a bash command line snippet (or other code is fine too I guess)
that will fix all my directory tree?
 
The tricks are that I think there can be several variations and several
instances with a given file too:
 
     require_once('/path/to/my/file');
     require_once ('/path/to/my/file');
     require_once("/path/to/my/file");
     require_once(ROOTPATH."/my/file");
 
etc. Note the space before the parens, the single vs. double quotes and the
use of a global define.

I think this regex should work:

	require_once\s?\((.*?)\);

I just don't know the magic sed/awk/grep/whatever to do the search and
replace on all my .php files recursively.

This seems like a useful 'routine' to post up on that page, as I'm sure I'm
not the only one who didn't know this little subtlety (considering PHP
doesn't puke on it either).


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux