我有一個的index.php這條線:PHP如何獲得,其中包括頁面的URL使用
<?php echo (file_get_contents("http://www.mydomain.com/includes/header.php")); ?>
在header.php中,我想包括DIV secion只有訪問者在www.mydomain.com/index.php其餘的我想隱藏這個。
我打算使用$_SERVER['SERVER_NAME']
和REQUEST_URI
來獲取位置,然後使用IF來檢查頁面是否爲index.php ELSE不顯示DIV部分。
的問題是,如果我把它搬進header.php中我得到的網址是www.mydomain.com/includes/header.php insted的www.mydomain.com/index.php
任何的想法如何解決這個問題?
爲什麼一個普通的的file_get_contents instea包括?? – Steve