Building an include() file path with concatenation.

I have files to include in the format “name_type.php”, and I’m loading the page as “url.php?name=example”.
I want to generate an include for specific files using ‘name’ to get the correct one. So far I’ve tried the following and nothing seems to work.

[php]$link = ‘/filepath/’ . $_GET[“name”] . ‘_type.php’;
include($link);[/php]
[php]include(’/filepath/’ . $_GET[“name”] . ‘_type.php’);[/php]
[php]$path = ‘/filepath/’;
$ext = ‘_type.php’;
$link = $path . $_GET[“name”] . $ext;
include($link);[/php]

I’ve also tried sticking them in eval(); functions but that returned NULL each time. Is there a certain way this needs to be done for it to work?

can you post the error? maybe there is something wrong with your path.

try removing the ‘/’ before filepath

include(‘filepath/’ . $_GET[“name”] . ‘_type.php’);

Hi Franz,

Why not remove “/filepath/”? So long as “name_type.php” and “url.php” are on the same directory, it should work.

By the way, try use POST.

Cheers. :slight_smile:

Sponsor our Newsletter | Privacy Policy | Terms of Service