Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Include Folder Contents

Status
Not open for further replies.

PCHomepage

Programmer
Feb 24, 2009
609
US
On a local Intranet site, I would like to be able to include all the individual files in a folder into another script without having to name each and every one in its own "include" line. In other words, the files will each contain a function and I want any that are there in the folder to be included automatically.

Although security is not a major issue, what folder permissions would be best?

Unfortunately I am a bit rusty on my PHP! Can anyone help get me started? Thanks.

Don
 
First I should point out that security is always an issue unless it's on it's own little intranet and you are the only user.

Now that that's out of the way.

Take a look at The examples show you how to read all the files in a directory - which CAN be used to include them.

A better way would be to use Object-Oriented Programming and stick the functions in classes. Then Autoload the classes as necessary using this method: There are still security issues either way though the OOP autoload method is marginally better.
 
Thanks! That is exactly what I needed to know and I appreciate the very fast answer. Probably the audoloading of classes is a better choice although the reading of files in a directory might have some uses for my "experiment" too.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top