Hi,
I’m having problems referencing an array in my php file. This is an included file. The array is declared and initialize outside of any functions called. I wanted to use the array as a lookup table for file locations. however, from within a function the array is undefined. Maybe I’m just not understanding scope in php. Anyway, here is some sample code:
$sysfiles = array(
“notify” => dirname($_SERVER[‘DOCUMENT_ROOT’]).DIRECTORY_SEPARATOR.“appFiles”.DIRECTORY_SEPARATOR.“notifyendpoint.txt”,
“client” => dirname($_SERVER[‘DOCUMENT_ROOT’]).DIRECTORY_SEPARATOR.“appFiles”.DIRECTORY_SEPARATOR.“clients.txt”,
);if(!function_exists(‘getfilecontents’)){
function getfilecontents(string $file){
$filename = $sysfiles[$file];
return preg_replace(’/[[:cntrl:]]/’, ‘’, $file);
}
}
Within this test code(Which I know does nothing yet) I get an undefined variable error when I reference $sysfiles. It is declared and I can print_r it from outside the function.
Any thoughts?
Thanks