Web Hosting Talk







View Full Version : quickie php include() question


[Avarice]
10-03-2000, 08:27 PM
hey using php, how do i make it so that the include() includes a file that is a variable...
like if i type in http://www.blah.com/template.php?var1=page1 how will i make it so that the php include() includes page1.inc

Félix C.Courtemanche
10-03-2000, 08:50 PM
in your file template.php, have something like:
<?
if (isset($var1.".inc")) include($var1.".inc");
?>

This will check if the file exists (isset command) then include it.
however, you should REALLY rename your .inc to .inc.php because if someone opens the file.inc directly, he will be able to read your raw un-parsed php code... which is not a good thing at all.