In this example, the getRoot method is used with the getcwd() function to get the root directory of the server and then it is displayed using the echo statement. Package Library: This method is a built-in function in PHP and doesn't require any third-party library or package.