Link to home
Start Free TrialLog in
Avatar of hankknight
hankknightFlag for Canada

asked on

PHP: OS Appropriate Directory Separator

I want $SystemSlash to either be / or \ depending on the operating system.

How can I make $SystemSlash be the appropriate directory separator for the operating system used?
<?php

echo $SystemSlash . 'path' . $SystemSlash . 'to' . $SystemSlash . 'my/file.php';

?>

Open in new window

Avatar of k_romych
k_romych

if (strpos($_SERVER['DOCUMENT_ROOT'],'/')){$SystemSlash='/';}else{$SystemSlash='\\' ;}
ASKER CERTIFIED SOLUTION
Avatar of Rik-Legger
Rik-Legger
Flag of undefined image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial