Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Include Help
palli
post Apr 4 2005, 10:37 AM
Post #1


Newbie
*

Group: Members
Posts: 1
Joined: 4-April 05
From: Iceland
Member No.: 5,244



Need help to include this, i am trying to include this folder
http://www.koddinn.com/shoutbox_v1.2/shoutbox.php to this http://www.koddinn.com/test.php

the folder include many files
http://www.koddinn.com/shoutbox_v1.2

i want to include all the files in a certain directory. do i use reddir for this, how can i do this

CODE
echo "<PRE>";
$handle = opendir(".");
while($file = readdir($handle)) {
if(is_dir($file)) echo "$file/\n";
else echo "$file\n";
}
closedir($handle);
echo "</PRE>";


do i have to loop to include each file.

??
Go to the top of the page
 
+Quote Post
round
post Apr 5 2005, 01:25 AM
Post #2


Super Member
*********

Group: Members
Posts: 463
Joined: 8-November 04
Member No.: 2,186



I don't think you can include a whole folder. I think you can work it out so that your directory list is included like a config file that gets updated when your directory is changed(when files are deleted or created. I would love to help but don't have time right now. If you look on php.net you might be able to something there that might help you out.
round
Go to the top of the page
 
+Quote Post
Spectre
post Apr 5 2005, 03:17 AM
Post #3


Privileged Member
*********

Group: Members
Posts: 874
Joined: 30-July 04
Member No.: 246



I would recommend going with round's suggestion. A folder may contain other files that you do not wish to include, such as, for example, .htaccess. Having a configuration file which explicitly specifies which files to include might take a little longer to put together, but would be a much better idea overall.
Go to the top of the page
 
+Quote Post
no9t9
post Apr 5 2005, 03:33 AM
Post #4


Privileged Member
*********

Group: Members
Posts: 773
Joined: 4-November 04
Member No.: 2,118



$dh = opendir("shoutbox_v1.2");
while ($temp=readdir($dh)) { if ($temp!="." && $temp!="..") { include($temp); }}

this will include all files in your "shoutbox_v1.2" directory. IF you want to skip certain files, just add them in the IF condition. Right now, the if condition skips "." and ".." because those are not files.

You also might want to add $temp!=".htaccess" as well...

you can also exclude (or include) files using string functions like eregi and strstr. For example, if you only want to include .php files you only need 1 condition in the if statement.

example: if (eregi("\.php",$temp)) will only include php files from the directory "shoutbox_v1.2"

another example: if (eregi("\.php",$temp) || eregi("\.html",$temp)) will include all .php files and .html files

anyway, modify the if condition to do what you want it to.
Go to the top of the page
 
+Quote Post
no9t9
post Apr 5 2005, 03:36 AM
Post #5


Privileged Member
*********

Group: Members
Posts: 773
Joined: 4-November 04
Member No.: 2,118



no edit button...

you might have to add the directory in front of the $temp variable for your include statement.

include ("shoutbox_v1.2/".$temp);

this depends on where you call this script. IF it is within the shoutbox_v1.2 directory, you don't need it. If it is in the root (which your original post suggests), you will need it.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Php's Include Function (info)(10)
  2. Executing Scripts Without Include() Function(3)
  3. Can Header Files Include Each Other?(2)
  4. Php Include Script(6)
  5. Php And Flash Movie Ie Problem(2)
  6. Sprites Full Sig Tutorial V2(15)
  7. Changing Include Tag On All Pages(11)
  8. Loading Some Of The Title From The Include Tag(2)
  9. Php Include Root Ref(6)
  10. Is Ssi Available ?(5)
  11. Include File.php?id=something(13)
  12. How To? Include Website In Search Engine..(3)
  13. Would A New Tech Include A Game Engine?(2)
  14. Include Funtion Php Problems(11)
  15. Include And Values(3)
  1. Where Is Include Path?!(5)
  2. Topic View Changed To Include Custom Fields(3)
  3. Include() Statements(4)
  4. Php Include Troubles(6)
  5. Text Image Java Problem(1)
  6. Php Include Problem [resolved](4)
  7. Harry Potter: The Deathly Hallows(18)
  8. Hosting Account Should Include Wysiwyg Editor(7)
  9. Does Php Include Work?(17)
  10. How Do I Include A Php Sidebar In My Website?(5)
  11. Question About Php Includes(17)
  12. Php - Forms, Date And Include(0)
  13. Php Allow Url Include Question!(10)


 



- Lo-Fi Version Time is now: 6th October 2008 - 06:09 PM