Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Including!
Index -> Programming, PHP -> PHP Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Amailer




PostPosted: Thu Jul 03, 2003 8:55 pm   Post subject: Including!

HELP!!

code:

$include = array('function, 'mysql');


for($j=0; $j < count($include); $j++)

include $include[$j].".php, ";


THAT DOES NOT WORK!,
ITS SUPPOSE TO INCLUDE THE FILES "function" AND "mysql", but i guess i could not do it that way.

CAN ANYONE TELL ME A WAY TO INCLUDE MORE THEN 1 FILE USING 1 INCLUDE LINE? (THATS :
code:
INCLUDE "WHATEVER";
)

THANK YOU!
Sponsor
Sponsor
Sponsor
sponsor
PaddyLong




PostPosted: Thu Jul 03, 2003 10:36 pm   Post subject: (No subject)

umm, it looks like you have typos in your code is all because I have done plenty of stuff like that before... you seem to be missing a ' after function in your array declaration and also I am unsure why you have a , and space after .php in your include statment

also are you sure that your directories are correct (like that there shouldn't be some directory on function.php and mysql.php)?
Amailer




PostPosted: Thu Jul 03, 2003 10:46 pm   Post subject: (No subject)

ok ok ok the code works and

code:

$include = array('function', 'mysql');


for($j=0; $j < count($include); $j++)

include $include[$j].".php";


Ok thats how it is..its correct, the thing is that hte include ""; does not allow more then 1 file WHAT I MEAN IS i.e. include "file.php, file2.php...it goes on";

So is there a way that i can make it include more then one file, rather then doign.

code:

include "file1.php";
include "file2.php";
include "file3.php";
...


Anyone would like to help?
PaddyLong




PostPosted: Fri Jul 04, 2003 12:14 am   Post subject: (No subject)

shouldn't it be
code:

$include = array('function', 'mysql');


for($j=0; $j < count($include); $j++)

include $include[$j].".php";


you were still forgetting the ' after function in your array declaration
Amailer




PostPosted: Fri Jul 04, 2003 2:39 pm   Post subject: (No subject)

Ah yes, ok ok i know, but the include does not allow:
code:

<?
include "function.phpmysql.php";

//OR

include "function.php, mysql.php";

?>


which is what the script above ( on the above post you posted/edited )
does....Is there another way?
octopi




PostPosted: Fri Jul 04, 2003 9:23 pm   Post subject: (No subject)

I don't see the point of what you are trying to do, but this works:


code:
<?php
function includefiles($list) {
  $list = explode(", ",$list);
  foreach ($list as $file) {
    include_once($file);
  }
}

includefiles("a.php, b.php, c.php");
?>
Amailer




PostPosted: Fri Jul 04, 2003 9:54 pm   Post subject: (No subject)

thx, point is that im includign more then 20 files from diffrent places Smile (( not ont he sameserver))
its kidna stupid...but yes
PaddyLong




PostPosted: Fri Jul 04, 2003 10:11 pm   Post subject: (No subject)

what's wrong with the for loop and array?
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, PHP -> PHP Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 8 Posts ]
Jump to:   


Style:  
Search: