I think it would be a good idea to create some sort of config file (XML maybe) that holds the known paths. This way it can be easily updated by the user and allows more paths to be added without touching the PHP code.
However, having tried out your proposal on a German XP box, the following issues have to be addressed, keeping in mind that I run PHP 5.1.2 with E_STRICT:
M:\SDev>php ../php/pear/docs/system_folders/examples/example.php
PHP Warning: require_once(Folders.php): failed to open stream: No such file or directory in M:\PHP\PEAR\docs\system_folders\examples\e
xample.php on line 6
PHP Fatal error: require_once(): Failed opening required 'Folders.php' (include_path='.;M:\PHP;M:\PHP\PEAR;M:\PHP\PEAR\tests;M:\SDev;M
:\SDev\WinBinder') in M:\PHP\PEAR\docs\system_folders\examples\example.php on line 6
M:\SDev>php ../php/pear/docs/system_folders/examples/example.php
PHP Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in M:\PHP\PEAR\System\Folders.php on line 56
PHP Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in M:\PHP\PEAR\OS\Guess.php on line 102
PHP Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in M:\PHP\PEAR\OS\Guess.php on line 103
PHP Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in M:\PHP\PEAR\OS\Guess.php on line 104
PHP Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in M:\PHP\PEAR\OS\Guess.php on line 105
PHP Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in M:\PHP\PEAR\OS\Guess.php on line 106
array(8) {
["Home"]=>
NULL
["Documents"]=>
NULL
["Shared documents"]=>
NULL
["Temp"]=>
string(16) "C:\WINDOWS\Temp\"
["Desktop"]=>
NULL
["AppData"]=>
NULL
["Programs"]=>
string(13) "C:\Programme\"
["Windows"]=>
string(11) "C:\WINDOWS\"
}
After having corrected the import of 'Folders.php' to 'System/Folders.php', the example gives the above stated information.
Cursory code review:
- require_once is a language construct and not a function
- please try to be more PCS compliant, e.g. EOL at the file's end, file doc block not complete etc.