Duplicating / Creating a copy of the original file
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 开发者_Go百科/copies/test.php How do i do that ? and it would be better if i could rename it.
This'll do it:
<?php
copy(__FILE__,dirname(__FILE__).'/copies/'.basename(__FILE__));
?>
you want to copy all test.php php code or result from that code?
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...
精彩评论