3v4l.org

run code in 300+ PHP versions simultaneously
<?php // inside index.php $extra_scripts = ['file03.js']; ?> // now moving into header.php <?php $import_scripts = array_merge(array( 'file01.js', 'file02.js' ), $extra_scripts ?? []); ?> <!DOCTYPE html> <html> <head> <!-- Scripts Section --> <?php foreach ($import_scripts as $script) { echo '<script src="' . $script . '"></script>' . PHP_EOL; } ?><title>Demo</title> </head> <body> <p>Blog</p>
Output for 7.4.0 - 7.4.33, 8.0.1 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.27, 8.4.1 - 8.4.14
// now moving into header.php <!DOCTYPE html> <html> <head> <!-- Scripts Section --> <script src="file01.js"></script> <script src="file02.js"></script> <script src="file03.js"></script> <title>Demo</title> </head> <body> <p>Blog</p>

preferences:
114.47 ms | 407 KiB | 5 Q