I need a reliable way to determine where the Web root folder is, relative to the FTP root folder using only PHP commands.
For the purposes of this question, please assume that the FTP server and the Web server are both running on the same machine and that the FTP server's root folder is an ancestor folder of the Web server's root folder.
eg. On a typical LAMP server:
$_SERVER['DOCUMENT_ROOT'] == '/home/username/public_html'
and FTP root folder == '/home/username'
If I use PHP's "ftp_pwd()" command it will return '/' and if I use "ftp_nlist()" it will include the actual 'public_html' folder in the output listing array, but there's no obvious way to establish with absolute certainty if that 'public_html' folder really is the Web root folder.
ps. I'd like to be able to do this for any flavour of Web server and FTP server