开发者

Duplicating / Creating a copy of the original file

开发者 https://www.devze.com 2023-01-24 03:43 出处:网络
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

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...

0

精彩评论

暂无评论...
验证码 换一张
取 消