I am writing an application based on php. Can anyone guide me how to remove or strip comments for my entire application, which is about 100 php files?
Maybe any public utility or class. Or any low-cost or open-source IDE ?
How to strip/remove comments for 100 php files?
If you mean, you want to delete comment lines from the code, you can do that with a decent text editor.
Or, if you want to do it with a PHP page itself, you can simply use regular expressions to locate comments and remove them. Using eregi_replace, it would be:
eregi_replace( '(?:/\*[\w\W]*?\*/|//[^\n]*? $|\#[^\n]*?$ )', '', $input);
Reply:If you processes each file line by line it can be done.
%26lt;?php
if ($handle = opendir('./phpfiles')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." %26amp;%26amp; $file != "..") {
// process file
$lines = file($_GET['file_name']);
$l=0;
// depending on type of comments used this may need to be adjusted
while($l%26lt;count($lines))
{
//process line
// This following is a rough idea of how this could be accomplished
// there are generally 3 types of comments in php
// double forward slashes, pound symbol and forward slash followed by
// an asterick, which also needs a closing asterick and forward slash
if(isNotAComment($lines[$l]))
{
if($outputfile=fopen(readdir('./output... "a"))
{ //open file for writing
fwrite($outputfile, $lines[$l]); //write to file
}
}
}
}
closedir($handle);
}
?%26gt;
Reply:use textpad. It's a great product where you can search and remove text of any sort or programming language. Textpad.com
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment