2015-07-01 98 views
1

我已經瀏覽了檔案並閱讀了一系列有關PHP爲什麼無法工作的問題。我試着用其他問題的答案解決我的問題,但仍然有問題。另一個PHP包含問題

這是我的代碼:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Fuel Status Map</title> 
<link href="style.css" rel="stylesheet" type="text/css" /> 
</head> 

<body> 
<div id="main"> 
    <div id="map"> 
    <? 
    require 'MapLink.php'; 
    ?></div> 
    <div id="title"><img src="title.png" width="400" height="200" /> 
    </div> 
    <div id="links"> 

    <a href="statusbyzone.php"><img src="FuelStatusLink.png" width="400" /></a> 

    <br /> 
    <a href="selectoffice.php"><img src="NWSofficeLink.png" width="400" /></a> 
    <br /> 
    <a href="Login1.php"><img src="FuelSpecialistLink.png" width="400" /></a> 
    <br /> 
    <img src="AdminLink.png" width="400" /> 
    <br /> 

    </div> 
    <div id="legend"><img src="Legend1.png" width="400"> 
    </div> 
    <div id="logos"> 
    <img src="PSlogo.png" width="140" height="150" /> 
    <img src="GBlogo.png" width="250" height="150"/> 
    </div> 
</div> 
</body> 
</html> 

的頁面應該是這個樣子:http://www.directdocuments.com/GACC/GBSite/predictive/FuelStatus/FuelStatusMap.php 但看起來是這樣的:http://gacc.nifc.gov/gbcc/predictive/FuelStatus/FuelStatusMap.php 的MapLink.php是在同一目錄下,並且能夠正常運行。我也會發布鏈接,但我無法發佈更多鏈接。

+0

包含PHP代碼。是否有任何錯誤報告? – chris85

+0

您能否返回'get_include_path();'的值以確保php.ini配置不會在那裏干擾? – dlegall

回答

2

看起來您的PHP配置中沒有啓用短打開標記,因此require行正在逐字輸出(使用View Source來查看此內容)。使用完整的標籤。

<?php 
require 'MapLink.php'; 
?> 

documentation

PHP還允許較短的開放標籤<?(這是不鼓勵,因爲如果使用short_open_tag php.ini配置文件中啓用它僅適用,或者如果PHP是使用--enable-short-tags選項進行配置)。

又見Are PHP short tags acceptable to use?

+0

只是爲了闡述......這很好,'<?= $ someVariable?>'。短[標籤](http://php.net/manual/en/language.basic-syntax.phptags.php)雖然不是。網上應該有很多關於爲什麼短標籤被皺眉的原因。 – ficuscr

+0

我沒有意識到<?有區別。和<?php 你不知道你剛纔爲我解決了多少問題! –