How do I include a file that is determined from a function??

FairyBusiness
FairyBusiness used Ask the Experts™
on
Hi, I am trying to dynamically select which blurb to include on the page according to which link was clicked.

include 'header.php';
$blurb = blurbs();
var_dump($blurb);
include $blurb;
include 'footer.php';

Open in new window


But its not working even though 1blurb.php is a an active page:  http://gowiththemaster.com/tleithoff/1blurb.php

http://gowiththemaster.com/tleithoff/about.php?menu=1&type=1blurb

Anyone know how to do this?

// Determines which blurb should be included
function blurbs() {
	if(isset($_GET['type'])) {
		$blurb = $_GET['type'];
		$blurb = "'" . $blurb . ".php'";
		return $blurb;
	}
}

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2004
Commented:
Remote the single quotes, and it should work. Make sure to do some input validation, or a malicious user could include any file at all!

Author

Commented:
hmmmm not sure how I would do any input validation.  but thanks it worked!
Top Expert 2004

Commented:
You can have a list of allowed blurbs somewhere against which you can compare. Or you can parse the query string to remove ../ and only include files in a specific blurb directory.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial