Get server root path in PHP?

Get server root path in PHP?

You can use this code.

Create a php page, like get.php and add this code.

1
2
3
<?php
echo getcwd();
?>

This is quite useful when moving wordpress websites from a domain to another, from a webhost to another webhost.
If the server path on the old server is different, you will have to replace it from both the files and the sql database.

So basically you will have to know the server path on the old and the new server.

This is really important, otherwise you might get white screens in WordPress or various errors.

Add a comment: