Page 1 of 1

how to include file using function ?

Posted: Thu May 17, 2007 12:50 am
by PHPycho
hello forums !!
i would like to know if its possible to include file in a function..ie when a filename is given as an argument then it should be able to include that..
index.php

Code: Select all

doInclude("page1");
functions.php

Code: Select all

doInclude($file){
 return include($file.".php");
}
Will this function work ? else what s the effective function then, I would also like to make one for class files(to include it and create objects).
please Help.

Posted: Thu May 17, 2007 12:54 am
by feyd
For functions and classes, it will work. For variables, generally it will not. As for functionality to create objects, that's what Factories are for.