Skip to content

Instantly share code, notes, and snippets.

@shahariaazam
Last active December 11, 2015 18:38
Show Gist options
  • Save shahariaazam/4642401 to your computer and use it in GitHub Desktop.
Save shahariaazam/4642401 to your computer and use it in GitHub Desktop.
Platform Independent DIRECTORY_ SEPERATOR constant in php
<?php
function TestPath()
{
return __DIR__.DIRECTORY_SEPARATOR."somefile.php";
}
var_dump(TestPath());
/*
* it will return something like string 'C:\xampp\htdocs\LibComponent\Multimedia\somefile.php' (length=58)
* In this case DIRECTORY_SEPERATOR constant is "\" if I want to require somefile.php then this type of path will not work
* but to make it work I need C:/xampp/htdocs/LibComponent/Multimedia/somefile.php
*/
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment