Reputation: 417
I have a file test.php in that i want to add a PHP script in such a way that whenever test.php is being exceuted/opened it should copy itself to a directory /copies/test.php How do i do that ? and it would be better if i could rename it.
Upvotes: 1
Views: 145
Reputation: 165
This sounds like a very zoomed-in solution to a problem that might be much easier to solve. Have you thought about sharing the problem as a whole? You never know...
Upvotes: 1
Reputation: 11159
This'll do it:
<?php
copy(__FILE__,dirname(__FILE__).'/copies/'.basename(__FILE__));
?>
Upvotes: 1