i gibi bir menü varsa
<a href="index.php">home</a>
<a href="aboutus.php">about us</a>
<a href="contact.php">contact us</a>
menu.php adlı bir dosya içinde
ve bu menu.php dosya tüm uygulama karşısında sayfaları içine dahil olur. ama ne ben yeni bir klasör oluşturun ve portföy diyoruz ve bu klasörde örnek1.php adlı bir dosya var ve menu.php bu dosyada yer alırsa. hakkımızda ev, ve bize kök onların işaret beri artık alışkanlık iş bağlar. bu yüzden bu işlevi yarattı
function getRoot() {
$self = $_SERVER['PHP_SELF'];
$protocol = $_SERVER['https'] == 'on' ? 'https:/' : 'http:/';
$docroot_before = explode("/", $self);
array_pop($docroot_before);
$docroot_after = implode("/", $docroot_before);
$host = $_SERVER['HTTP_HOST'];
return $protocol.$host.$docroot_after."/";
}
ve menü şimdi bu gibi görünüyor
<a href="<?=getRoot();?>index.php">home</a>
<a href="<?=getRoot();?>aboutus.php">about us</a>
<a href="<?=getRoot();?>contact.php">contact us</a>
the link should come out as http://localhost/domain/aboutus.php (for example)
but it comes out as http://localhost:/domain/portfolio/aboutus.php (and this is wrong).
menu.php dahil alır nerede olursa olsun her zaman doğru doc kök almak için en iyi yolu nedir.?