PHP - Require with Folders

Asked

Viewed 21 times

-2

I’m running a PHP test (probably the longest test I’ve ever done), where I try to get all the files from a folder, using require, but automatically...

My files are like this:

  • PHP-Teste
    • index php.
    • public (Pasta)
      • Test.html
      • Style-Home.css

Well, my index.php looks like this:

<?php
require 'public/Teste.html';
require 'public/Style-Home.css';
?>

This code works perfectly, but now imagine that I had 100 files, I would have to do the require manually on each one? Like there’s no way to get one require 'public/*' or something like?

Ah, and if you have a more suitable way of showing HTML, CSS, JS, ETC files in PHP, you can give the hint :)

  • Create an array with the name of the files to be included, itere by this array including each element.

  • @Augustovasques . I’ve tried it this way, but it includes the files together, without any folder. Problem is: In my index.html, it is searching for CSS like this: css/style-home.css . Css is in a folder (In normal environment)

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.