Search code examples
phpglobnetwork-share

PHP - dollarsign in file path


How to access files with a $-sign in a network share?

\\server\data$\fileshere

Tried escaping the backslashes, but my guess is that it's the dollarsign that creates problems?

EDIT:

Okay - here goes. On the server there is this file :

\\server\data$\filetest.txt';

If I want to check for a wildcard match like 'file*' my code looks this this :

$filecheck = '\\server\data$\file*';
## (also tried escaping \ : $filecheck = '\\\\server\\data$\\file*';
$check = glob($filecheck);

It does not match.


Solution

  • You have not added enough backslashes for the UNC part, also its safest to escape the escape char so always use \\ for one backslash.

    Use

    $filecheck = '\\\\server\data$\file*';
    

    It also works for me using

    $filecheck = '\\\\servers\\data$\\file*';