Jump to content

auto html comments


yhi
 Share

Recommended Posts

i want to add comments in JS & PHP files there are 22K files

so i cant do it manually

 

i need a php script which i can run & it should add my comment in all files

 

please give me a script which will add my comment in top line of all PHP and Js file

 

i can run script separately for php & JS

 

 

PS

please make sure script dont change anything else on those php& JS source code

 

 

 

thanks for the help

Link to comment
Share on other sites

Yes - a fopen would be a good start.

 

But - as I re-read your post - if you have written (?) 22k files, then why can't you figure this out for yourself???

 

Or maybe you didn't write them. In that case what is this 'comment' you want to add? A statement of authorship perhaps?

Edited by ginerjm
Link to comment
Share on other sites

We are not a code on demand service. Either post in the "for hire" section or show your attempt.

seems fair :)

 

 

here

 

 

<?php

$comment=" blah blah";

foreach ($files as $file){
$code=file_get_contents("$file");
$finalcode="$comment$code";
$writefile = fopen("$file","w");
echo fwrite($writefile,"$finalcode");
fclose($file);	
	
}



?>

i am not sure how to read read all files name in all directories

Edited by yhi
Link to comment
Share on other sites

i want to add comments in JS & PHP files there are 22K files

so i cant do it manually

 

i need a php script which i can run & it should add my comment in all files

 

And what purpose are these "comments" going to fulfil?  Presumably, you'll be adding the same thing to each and every one, which begs the question - what's so important that it has to be in every file? 

 

Boiler plate comment blocks are probably of very little practical value or, indeed, downright "harmful" (see: https://dzone.com/articles/meaningless-docblocks). 

 

Regards,   Phill  W.

Link to comment
Share on other sites

Notwithstanding the questions about "what is this comment?" you could do things a bit differently.

 

1 - add a \n\r to the comment so that it stands on a line by itself.

2 - use file_put_contents to output the new file.

3 - Read the Manual to learn more about PHP.

Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.