note 27617 deleted from function.include by victor

From: Date: Fri, 13 Dec 2002 08:22:09 +0000
Subject: note 27617 deleted from function.include by victor
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-40851@lists.php.net to get a copy of this message
This took me a good 30 minutes to figure out because my brain wasn't working at the time. Still, it could help beginnersnsuch. If you have a php file that is calling a template file so that, for example, you can use a single template for multiple things easily, you can set a variable to make it work. My explanation of why I needed this isn't good, but here it is: <?php if($u == '') $u = "default file to include"; include($u); ?> This is the template file. It is including a file into the 'body' of itself to make your life simpler so you don't have to continuously copy and paste the nav bars and such that go AROUND the body. The default file is so that if someone accesses just the template by itself it won't make errors. <? $u="thing to stick in template's body"; include ("main.php"); ?> This is the file calling the template. It sets the thing you want to be in the template's body to a variable as used above, then includes it. That way the variable will exist and the template will load the correct file. Mainly this is just to make it look nice, the file calling the template is probly useless. Still, if you were to give people say, the ability to add a query string after it (templatefile.php?query) then it could be abused.

« previous php.notes (#40851) next »