2013-05-25 64 views
0

大家下午好。我被困在一個包含我所有'頭部'信息的文件中。我想打破我的頁面,所以它更簡單,更簡單。在我的index.php文件中,我做到了這一點;php包含文件執行失敗

<?php 
include 'Resources/includes/head.php'; 
?> 

找到文件,我知道這一點,因爲在Dreamweaver當我我的索引頁轉到它出現,因爲它下方的標籤。但是,當我在本地服務器上查看我的索引頁面時,就好像沒有樣式或腳本已應用於頁面。這是我的head.php文件中的代碼。

<head> 
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> 
    <meta name="description" content="" /> 
    <meta name="keywords" content=""/> 
    <link rel="shortcut icon" href="../images/design/icon.png" type="image/x-icon"/> 
    <link rel="stylesheet" href="../css/style.css" type="text/css" media="screen"/> 
    <script src="../js/jquery-1.8.3.min.js" type="text/javascript"></script> 
    <script src="../js/scripts.js" type="text/javascript"></script> 
    </head> 
+0

你有問題,你的基本主題路徑嘗試這樣的事情。您可以嘗試通過刪除..或添加../或通過定義文件夾的基本路徑來檢查。 – sAnS

+0

它發現它只是不執行其中的信息的文件夾。 –

+0

我已經添加了一個示例答案,您可以嘗試這樣做。 – sAnS

回答

0

您可以通過使用基本路徑

<?php 
$basepath="http://www.mysite.com/path_to_theme/"; 
?> 

<head> 
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> 
    <meta name="description" content="" /> 
    <meta name="keywords" content=""/> 
    <link rel="shortcut icon" href="<?php echo $basepath; ?>/images/design/icon.png" type="image/x-icon"/> 
    <link rel="stylesheet" href="<?php echo $basepath; ?>/css/style.css" type="text/css" media="screen"/> 
    <script src="<?php echo $basepath; ?>/js/jquery-1.8.3.min.js" type="text/javascript"></script> 
    <script src="<?php echo $basepath; ?>/js/scripts.js" type="text/javascript"></script> 
    </head> 
+0

似乎沒有工作 –

+0

你有一個在你的本地主機的htaccess ..你能夠直接訪問文件上的URL ..看起來像你的文件沒有執行,因爲在本地服務器的任何阻止策略 – sAnS

+0

有沒有問題就像那樣,到其他頁面的所有鏈接都正常工作,如果我想將「head」部分從文件中取出並直接放在index.php中,它就可以正常工作。但是我想盡量減少index.php上的內容,因爲它太擁擠了。加上這種方式,我可以更容易地編輯所有的內容 –