Jump to content

Auto Generate Multiple Includes


mgarant

Recommended Posts

Hello all,

 

I'm a brand new user of this forum, and made a little search about my problem before posting, but couldn't find any straight-forward answer to my question... So here i am!

 

What I'm trying to do is to include all my php files dynamically.... (I do the same for JS and CSS files and it is working great) Let me explain...

 

I run a php script that start from the root of the web site and iterate through all the folder and subfolders and returns all the files contained in the web site directory. Everything is working fine for that. What i don't know how to do is generate all my php includes from that script. For the JS and CSS it is quite easy... juste generate a big string containing the all <script> tags... same goes for CSS... but for php, I have no idea how I could transfer my includes from the script to the page calling the script. Here is a code sample

 

<?php
  include("path/class.websitehelper.php");
  $Websitehelper = new Websitehelper();
  $includes = $Websitehelper->GenerateIncludes();

  //To use/plug the JS scripts
  echo $includes['JS'];
  //To use/plug the CSS
  echo $includes['CSS'];

//How do i plug the php includes?????
?>

 

 

Anyone have any idea?

 

Thanks a lot!

Link to comment
https://forums.phpfreaks.com/topic/230023-auto-generate-multiple-includes/
Share on other sites

Thanks for the quick reply taquitosensei !

 

That is what i am actually doing, but it can be a real pain in the ass to do this when you have like 100 php files... And when you add one, or change the name of one file... it is a pain as well to change it... That is why I want to generate these includes dynamically by iterating through all the files in the website directory...

 

Any other ideas on how I could achieve this?

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.