Computer Science Canada

Including!

Author:  Amailer [ 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!

Author:  PaddyLong [ Thu Jul 03, 2003 10:36 pm ]
Post 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)?

Author:  Amailer [ Thu Jul 03, 2003 10:46 pm ]
Post 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?

Author:  PaddyLong [ Fri Jul 04, 2003 12:14 am ]
Post 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

Author:  Amailer [ Fri Jul 04, 2003 2:39 pm ]
Post 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?

Author:  octopi [ Fri Jul 04, 2003 9:23 pm ]
Post 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");
?>

Author:  Amailer [ Fri Jul 04, 2003 9:54 pm ]
Post subject: 

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

Author:  PaddyLong [ Fri Jul 04, 2003 10:11 pm ]
Post subject: 

what's wrong with the for loop and array?


: