I'm currently working on a PHP project and I'm facing an issue with the glob() function. So, the problem is that when I try to use a variable as the parameter in glob(), it returns no result. Let me explain it further.
I have a variable that contains a directory path, let's call it $directory. And when I try to use it like this: glob($directory), the function doesn't return any files or directories, even though there are definitely files present in that directory.
However, if I use the actual directory path directly in the glob() function like this: glob('/path/to/my/files'), it works perfectly fine and returns the expected results.
I've double-checked the value of $directory using var_dump() and it does contain the correct path. So, I'm really confused as to why glob() is not working when I pass the variable.
I have tried various solutions like using realpath() on the $directory variable before passing it to glob(), but it didn't make any difference.
Could someone please help me figure out what might be causing this issue? Am I missing something here? It would be greatly appreciated.
Thanks in advance.