Reputation: 11
I want to include different files, depending on a parameter passed to get
method. E.g. if the id
passed in the URL is 101
then I want to include file_101.php
. Here is what I have so far:
if(cat_id == 101)
{
$filename="file_101.php";
}
//some code here
include('$filename');
I have also tried:
include('echo $filename;');
but it is giving error
include() [function.include]: Unable to access echo $filename;
Upvotes: 1
Views: 81
Reputation: 605
Your echo is too many! You can include file with:
include 'file.php';
Or you can use methods that others have written.
Replace with $cat_id cat_id also!
PS. I counsel you to specify the name of the file that you include without variables.
Upvotes: 0
Reputation: 219824
Get rid of the single quotes. They make PHP parse the $
as a literal dollar sign instead of the beginning of a variable name.
include($filename);
Upvotes: 6