黃聖琪
黃聖琪

Reputation: 3

PHP glob can't read tmp

I am using wamp in win7, and I try to read c:\wamp\tmp by glob with php, but the result is an empty array

print_r(glob("C:\wamp\tmp\*"));

I can see any folder in c:\wamp except c:\wamp\tmp, and I make sure that folders has the same setting about read write...

Upvotes: 0

Views: 222

Answers (1)

Barmar
Barmar

Reputation: 782529

\t is an escape sequence that means the Tab character. You have several ways to deal with it:

  1. Escape it with another backslash.

    print_r(glob("C:\wamp\\tmp\*"));
    
  2. Use single quotes instead of double quotes, since escape sequences aren't processed in single quotes.

    print_r(glob('C:\wamp\tmp\*'));
    
  3. Use forward slashes instead of backslashes, since Windows allows either as a directory separator.

    print_r(glob("C:/wamp/tmp/*"));
    

Upvotes: 2

Related Questions