嗨我試圖讓一塊HTML只顯示在主頁上,這是http://www.domain.com/ ...我寫了下面的代碼,但它不起作用的HTML顯示無論頁面,我錯過了什麼
<?php
$hweb .= 'http://' .$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
if ($hweb == 'http://www.domain.com/'):
?>
<div style="margin:0 auto;">
<div style="float:left">
<?php endif; ?>
您是否嘗試過'$ hweb'上的回顯以查看它的作用?和'。='?在這種情況下'$ hweb = ...;'更有意義 –
是的,我回應了它,它返回了http://www.domain.com/,當它在另一個頁面http://www.domain.com/ page.html所以$ hweb變量正在工作 – acctman
(如果)它返回domain.com,我發現你的問題。缺少斜線。因此,您將「http:// domain.com」與「http:// domain.com /'相匹配。哦,等等,那不是你的問題。對不起 –