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
Post a Comment