web sitesi host ve docroot

3 Cevap php

Sunucudan hostname ve document root almak için PHP bir yolu var mı? Ben php kod değişken olarak saklayarak olmadan bunu yapmak istiyorum. Ben güvenilir ve saldırı tabi değildir duydum çünkü ben $ _SERVER kullanmaya isteksiz duyuyorum. Bu nasıl bir sanal konak üzerinde yapılabilir? Güvenilir ve güvenli bir yöntem var mı?

3 Cevap

Eğer deneyebilirsiniz

$docroot = getenv("DOCUMENT_ROOT");

getenv lets you access environment variables. You can see all variables that are available by printing phpinfo . Maybe apache_getenv da yardımcı olur.

Like you mentioned, you have access to : http://php.net/manual/en/reserved.variables.php There's a breakdown here of using realpath() and $_SERVER to get the doc root: http://www.helicron.net/php/

Ayrıca, ('host') ya da hostname almak için benzer bir şey exec olabilir.