11-10-2007, 11:31 PM
|
#1 (permalink)
|
|
The Frequenter
Join Date: Sep 2007
Posts: 360
Thanks: 24
|
Includes problem
I have index.php which has $var = 1;
I'm using the following function to include the template file.
function/function.php
PHP Code:
public function display($szView) { if (file_exists('views/' . $szView . '.php')) { include('views/' . $szView . '.php'); } }
The code of index.php is now:
PHP Code:
include('function/function.php'); $var = 1; display('home');
home.php is
But it doesn't echo the variable.
Directory structure.
- Root
- - function/function.php display() function is located here
- - views/home.php
- index.php
Why is the variables in index.php is not being parsed by home.php? When I simply include the file with include and not the function, it works.
|
|
|
|