Please help me find bug in my code. Why my function can't see varaibles, which is holded outside function?
$file['folder'] = "/files/";
$file['file'] = "myFile.txt";
$file['ip'] = "http://127.0.0.1:1234";
function patToFile($sql,$action){
$path = $file['ip'] . "/" . $file['folder'] . "/" . $file['file'];
return $path;
}
When I use pathTofile();
it returns "//". So it cant see variable outside.
- Why?
- How I can fix this?
EDIT:
I'm using global $file;
inside function, to tell function use global variables.