I am using the EOF function in my php code.
But I have a problem.
When I try to call a variable from another file, it simply ignores it.
I have a variable in another file(header.inc.php) that looks like this:
$site['url'] = "http://www.mydomainname.com";
Then I put the require function where the EOF code is:
require_once('../../inc/header.inc.php');
The file where the EOF code is , looks like this:
function getServices() {
$sCode .= <<<EOF
<a href="{$site['url']}" class="amenu">Home</a>
EOF;
return $sCode;
}
The variable $site[‘url’] is empty when I then call that function..
This is driving me crazy! Is there any reason why the EOF code should ignore that variable??
Try
global $site;as the first line in your function. Any global variables are not automatically visible in PHP unless you bring them into the function as globals.