note 42211 modified in class.dir by vrana
| From: | vrana@php.net | Date: | Thu, 05 Aug 2004 18:11:27 +0000 |
| Subject: | note 42211 modified in class.dir by vrana | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-74057@lists.php.net to get a copy of this message | ||
The Problem to make a script crawling through Windows and Unix directories is that Windows unses
'\' or '\\' and Unix uses '/' as diretory seperator.
To make a script running an both platforms you can use the PHP internal constant PHP_OS :
<?php
if ( strpos( PHP_OS, 'WIN' ) !== FALSE )
{ $dir_seperator ='\\'; }
elseif ( strpos( PHP_OS, 'Linux' ) !== FALSE )
{ $dir_seperator ='/'; }
?>
And now you can use the variable $dir_seperator for your [ rekursive ] crawling through directories.
--was--
The Problem to make a script crawling through Windows and Unix directories is that Windows unses
'\' or '\\' and Unix uses '/' as diretory seperator.
To make a script running an both platforms you can use the PHP internal constant PHP_OS :
if ( strpos( PHP_OS, 'WIN' ) !== FALSE )
{ $dir_seperator ='\\'; }
elseif ( strpos( PHP_OS, 'Linux' ) !== FALSE )
{ $dir_seperator ='/'; }
And now you can use the variable $dir_seperator for your [ rekursive ] crawling through directories.
http://php.net/manual/en/class.dir.php