On 30 April 2011 22:07, Tim Streater <t...@clothears.org.uk> wrote:
> Does it matter to PHP filesystem functions if a path/to/file/name contains 
> spaces? IOW, is this handled OK by design or should I replaces such spaces by 
> backslash-space or would doing that present problems?
> Thanks  --  tim

On Windows, PHP will happily access files and directories with spaces...

file_put_contents('My name is Richard.txt', 'Hello Richard');"

If you intend to pass the filename to a command line tool, then the
filename must be wrapped with double quotes ...

exec('tool.exe "My name is Richard.txt"');

If you intend to pass the filename to a command line tool and the tool
has spaces in the name too, then you need to wrap both with quotes ...

exec('"C:\Program Files\tool.exe" "My name is Richard.txt"');

If you are using a version of PHP before V5.3.0, please read
http://uk.php.net/manual/en/function.exec.php#101579. Your code would
need to be ...

exec('""C:\Program Files\tool.exe" "My name is Richard.txt""');

I've added some _ to that so you can easily see the single and double
quotes ... (they aren't part of the real code, just there to show you
the quotes) ...

exec(_'_"_"_C:\Program Files\tool.exe_"_ _"_My name is Richard.txt_"_"_'_);

Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to