5416339
5416339

Reputation: 417

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 /copies/test.php How do i do that ? and it would be better if i could rename it.

Upvotes: 1

Views: 145

Answers (3)

sentiao
sentiao

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

Nathan
Nathan

Reputation: 11159

This'll do it:

<?php
  copy(__FILE__,dirname(__FILE__).'/copies/'.basename(__FILE__));
?>

Upvotes: 1

Edmhs
Edmhs

Reputation: 3731

you want to copy all test.php php code or result from that code?

Upvotes: 1

Related Questions