-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgen.php
More file actions
29 lines (20 loc) · 842 Bytes
/
gen.php
File metadata and controls
29 lines (20 loc) · 842 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
$inputDirPath = './src';
$outputDirPath = './pages';
$headerContent = file_get_contents('./src/header.php');
$footerContent = file_get_contents('./src/footer.php');
// Get all PHP files in the input directory
$phpFiles = glob($inputDirPath . '/*.php');
foreach ($phpFiles as $file) {
// Skip the header.php and footer.php files
if (basename($file) === 'header.php' || basename($file) === 'footer.php') {
continue;
}
$fileContent = file_get_contents($file);
$modifiedContent = $headerContent . $fileContent . $footerContent;
// Change the file extension to .html and save to the output directory
$outputFile = $outputDirPath . '/' . basename($file, '.php') . '.html';
file_put_contents($outputFile, $modifiedContent);
}
echo "HTML files have been generated in the output directory.";
?>