I have the following line in a file named config.php:
$objects["settings"]["template"]["value"] = "yes";
Then a file named funcs.php which includes config.php, with the following lines.
echo $objects["settings"]["template"]["value"];
function testfunction() {
echo "<br />function output: ".$objects["settings"]["template"]["value"];
}
I then have index.php which includes funcs.php, as follows.
require_once("funcs.php");
testfunction();
How come the output from the function doesn't read the variables and they are empty?
yes
function output:
The output im expecting is:
yes
function output: yes
Thanks in advance.
EDIT: I went with Yoda's answer as it was the most detailed answer regarding passing $objects as a parameter. Thanks to everyone else who answered!
testfunctiondoesn't have access to the$objectsvariable.error_reporting(-1);at the top of your script.returninside the function andechooutside.global $objects;inside your function. Another woudl be to use the $GLOBALS array i.e. $GLOBALS['objects']["settings"]["template"]["value"]'