How to copy .php file [closed]

0

I have a database with fields: name I have an a.php file that will fetch the data name from mysql and fill it in a certain area of the page (content).

What I want is that as long as there are data in the database in the column "name" the file a.php is copied X times, changing its name and content.

Example: the A.php file is copied to ana.php and changes the contents of the page itself to "Ana"

How can I do this?

    
asked by anonymous 12.10.2017 / 12:33

1 answer

0

You can do this with fopen and fwrite :

<?php
    while ($row = $query->fetch_assoc()){ //Onde $query possui um objeto mysqli_result
        $nome = $row['nome'];
        $arquivo = fopen("$nome.php", "w");
        fwrite($arquivo, $nome);
        fclose($arquivo);
    }
?>
    
12.10.2017 / 14:53