Filesystem path creation function

Post removed (X-No-Archive: yes)
Notifier Deamon [ Di, 05 Oktober 2010 10:07 ] [ ID #2048875 ]

Re: Filesystem path creation function

On 5 October 2010 09:07, Gary <php-general [at] garydjones.name> wrote:
> Does such a thing exist in php? My searches have lead nowhere.
>
> What I am looking for is a function which you would pass two parts of a
> path to (which might be a directory and a filename, say) and it would
> return a string containing the parameters separate by the correct number
> of path separators according to the current OS.
>
> For example:
>
> <?php
> $d = 'foo';
> $f = 'bar';
> $path = createPathString($d, $f);
> ?>
>
> Would result in 'foo\bar' (Windows), 'foo/bar' (*n*x).
>
> And
> <?php
> $d = 'foo/'; // note the trailing slash
> $f = 'bar';
> $path = createPathString($d, $f);
> ?>
>
> on *n*x would also result in 'foo/bar' (i.e. the path would only contain
> one "/").
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

http://www.php.net/manual/en/dir.constants.php

--
Richard Quadling
Twitter : EE : Zend
[at] 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
Richard Quadling [ Di, 05 Oktober 2010 13:36 ] [ ID #2048882 ]

Re: Filesystem path creation function

On 5 October 2010 09:07, Gary <php-general [at] garydjones.name> wrote:
> Does such a thing exist in php? My searches have lead nowhere.
>
> What I am looking for is a function which you would pass two parts of a
> path to (which might be a directory and a filename, say) and it would
> return a string containing the parameters separate by the correct number
> of path separators according to the current OS.
>
> For example:
>
> <?php
> $d = 'foo';
> $f = 'bar';
> $path = createPathString($d, $f);
> ?>
>
> Would result in 'foo\bar' (Windows), 'foo/bar' (*n*x).
>
> And
> <?php
> $d = 'foo/'; // note the trailing slash
> $f = 'bar';
> $path = createPathString($d, $f);
> ?>
>
> on *n*x would also result in 'foo/bar' (i.e. the path would only contain
> one "/").
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Yep.

function createPathString($d, $f){return $d. DIRECTORY_SEPARATOR . $f;}




--
Richard Quadling
Twitter : EE : Zend
[at] 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
Richard Quadling [ Di, 05 Oktober 2010 13:34 ] [ ID #2048883 ]

Re: Filesystem path creation function

Post removed (X-No-Archive: yes)
Notifier Deamon [ Di, 05 Oktober 2010 14:17 ] [ ID #2048888 ]
PHP » gmane.comp.php.general » Filesystem path creation function

Vorheriges Thema: Connecting to MySql with PHP
Nächstes Thema: New to PHP and struggling with the basics