0

I'm currently using linux and in my PHP scripts, I've used slash many times. it takes time to install and config xampp in win so i thought this is fastest like this

foreach (scanAllDir($filePath) as $childFilename) {
     $result[] = $filename . '/' . $childFilename;
}

and

$customCssFile = fopen(__DIR__ . '/templates/custom-css.css', "w");

is this scripts works in windows? thanks

FadedForEver
  • 146
  • 10
  • You should be using `DIRECTORY_SEPARATOR` – treyBake Jan 20 '20 at 17:12
  • 3
    Yes, it should work. Q: What happens when you try it? – FoggyDay Jan 20 '20 at 17:14
  • I believe any recent (maintained) versions of Windows tolerate forward slashes for file paths. – Jeto Jan 20 '20 at 17:14
  • 1
    Although `DIRECTORY_SEPARATOR` is provided for determining which slash to use, I rarely find this constant useful outside of UI display context's. Both slashes will work the same on Windows however the backslash **will not** work on Unix/Linux. – Alex Barker Jan 20 '20 at 17:29

0 Answers0