I needed to understand how files are incorporated in php.

What i'm saying by that's that the way the variables in the incorporated files are imported and just how the incorporated file has the capacity to make use of the variables in the primary file.

I had been developing a templating system and also the problem was which i had a catalog file which incorporated another files for example config.php etc. However with respect to the page asked for the index.php contained web site files too. However for some some reason I wasnt able to utilize the variables in the config file from within the template.php file

below is vars.php


$color = 'green';
$fruit = 'apple';


below is test.php


echo "A $color $fruit"; // A

include 'vars.php';

echo "A $color $fruit"; // A green apple


simple one from http://php.net/manual/en/function.include.php

proclaiming global variables

$a = 1;
$b = 2;

function Sum()
    global $a, $b;

    $b = $a + $b;

echo $b;

have a look only at that http://php.net/manual/en/language.variables.scope.php

Variable scope comes.

You may also return something from an included file! Or else you may mostly think about the function to become simple, text-based (lexical) insertion.

See http://php.net/manual/en/function.include.php to learn more.