php - Copy single template to multiple file names -


i'm having little trouble multi file creation. i've taken code project creates pages 1 @ time in order.

trying create multiple pages of given template.php file.

i'm not getting errors in logs , nothing in destination. not understanding loops enough it's getting lost.

thanks in advance

<?php  // copy template.php -> page1.php, page2.php, page3.php etc...  $area = $_post["area"]; // number of needed pages $numberofpages = $_post["pagenumber"]; // location of template.php $templatelocation = "/var/work.files/template.php"; // send copied files requested location. $filedestination = "/var/work.files/$area";  ($i = 1; $i < $numberofpages; ++$i) {     // check if file name there. if there continue next in order     if (!file_exists($filedestination . '/page'. $i . '.php')) {         // filename , copy template ...         $filename = "page$i.php";         copy('$templatelocation', '$filedestination/$filename');        //continue until number of requested pages created     } }  ?> 

you used quotes incorrectly in code.
variables not interpolated inside single quotes.

change

copy('$templatelocation', '$filedestination/$filename'); 

to

copy($templatelocation, "$filedestination/$filename"); 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -