hello everybody,

i want to pass directory name as a variable in include function like this,

$page = 'test';
include('$page/test.php');

i know this a wrong way, but i don't know how to do it.
please anybody help in this regard.

Thank in advance....

Use double quotes. Single quoted strings aren't parsed.

$page = 'test';
include("$page/test.php");

# this will also work
include($page . '/test.php');

but this code is not working, some else solution please....

Member Avatar for Rhyan

The proposed code works 100%, but maybe you have not explained precisely what do you want to do, or what errors you have, etc.

What pritaeas proposed is a 100% working solution to what you have described in your first post as a requirement.

yes, it was my mistake. this code is working fine......
Thank you very much Pritaeas and Rhyan......

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.