"Dmitriy Sintsov" <[email protected]> wrote in message 
news:[email protected]...
> Backslashes are twice bad, because sometimes larger pathes are produced
> by concatenation of shorted "subpathes", and when one shorter subpath
> uses slashes and another one backslashes, the concatenated path is
> invalid even in Windows. For example, some MediaWiki extension failed in
> Windows because it used slashes and dirname() or getcwd() returned
> backslashes.
> That's why my extension uses:
> str_replace( "\\", "/", dirname(__FILE__) )
> Dmitriy

That's not my experience.  I have been using PHP for quite some time on both 
Linux and Windows, and will often use something like

  include(dirname(__FILE__) . "/../foo.php");

The path on a Windows box may therefore end up as something like:

  C:\some path\to\script/../foo.php

but this mixture of path separators has always worked fine for me, and 
others[1].  (Mixing separators won't work on *nix boxes of course, but 
that's not a problem in this case as dirname() returns paths in the local 
format).  The trick is to always use forward slashes, and it should work 
fine on all systems, even if it displays a bit funny in some situations.

The point about having to double-escape is true though.

- Mark Clements (HappyDog)

[1] http://us2.php.net/manual/en/ref.filesystem.php#73954 



_______________________________________________
Wikitech-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Reply via email to