Hello @kartik,
Try
$_SERVER['DOCUMENT_ROOT']
contains this path:
D:/workspace
In that case you could explode the string by slashes and return the first one:
$pathInPieces = explode('/', $_SERVER['DOCUMENT_ROOT']);
echo $pathInPieces[0];
This will output the server's root directory.
When you use the constant DIRECTORY_SEPARATOR instead of the hardcoded slash ('/') this code is also working under Windows.
Hope it helps!!
Thank you!!