2013-09-26 3 views
0

4 페이지를 압축하여 유지 관리하기가 쉽습니다. PHP를 사용하여 각 페이지의 공통 부분에 대한 "웹 파트"를 만들 계획입니다. 문제는 header.php 페이지가로드되어 모든 것을 표시한다는 것입니다.하지만 html 파일을 사용하면 PHP 페이지가로드되지 않습니다. 개발자 도구를 사용하고 더 이상 오류가 없으면이 문제를 일으키는 원인은 무엇입니까? 나는 include를 사용했고 변경된 작은 따옴표를 두 배로하고 읽거나 다룰 수있는 모든 것을 요구합니다. 하나의 HTML 페이지와 PHP 페이지 만 붙여 넣을 것입니다. 내 서버 기능 내가 QuickPHP을 사용하고PHP include/require 함수가 작동하지 않습니다.

HTML :

<!DOCTYPE html> 
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
    <link rel="stylesheet" type="text/css" href="styles.css"> 
    <script type="text/javascript" src= "clock.js"></script> 
    <script type="text/javascript" src= "links.js"></script> 
    <meta charset = "utf-8" /> 
     <title> 
     CSE Center for Health Information Technology 
    </title> 
</head> 

<body onload="time()"> 

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

    <div class = "content"> 
    <p> 
    <ul> 
    <strong> 
     <div class = "color">Lastest News!</div> 
    </strong> 
    <li> New Positions open at CHIT, click above link to see if you qualify! 
</li> 
    <li> New hospital being built in Canton, GA. </li> 

<li> CHIT signed agreement with Federal Government to be initiate country wide review 
</li> 
    </ul> 
    </p> 

    <p> 
    <strong> 
     General Information about the Center for Health Information Technology: 
    </strong> 
    <br /> 

CHIT was formed to provide certification and compliance 
testing services both to organizations that build and market HIT systems, 
and to healthcare providers and hospitals who have implemented HIT systems. 
    <br /> 

Conduct research into the issues that healthcare providers and hospitals face 
in selecting, implementing, and integrating HIT systems. 
    <br /> 

Conduct research and develop tools to strengthen the privacy and security 
of health information, and help people understand their rights and the resources 
available to safeguard their personal health data. 

<!-- All three of these came start from http://cse.spsu.edu/chit/index.shtml --> 
    <br /> 
    </p> 
    </div> 
    <p> 
     <h2>Current Time</h2> 
     <h2 id="currenttime">now</h2> 
    </p> 
</body> 
</html> 

PHP : 그것은 .html 중에서 확장자를 볼 수 있기 때문에

<div class = "header"> 
    <p> 
    <a href="http://www.spsu.edu"> 
<img src=" http://spsu.edu/_resources/images/img_index_logo.png" 
    alt="SPSU Home" width="263" height="119" border="0"/></a> 
    <br /> 
    <a href="http://cse.spsu.edu"> SPSU's CSE Home Page <br /> </a> 
    </p> 

    <p> 
    <h1> 
     Welcome to the Center for Health Information Technology 
    </h1> 
    </p> 

    <div id="pagelinks"> 
    <p> 
    <strong> 
     Page Links! 
    </strong> 
    <br /> 
     <select name="links" id="pagelink" onchange="linkchange()"> 
     <option value = "" >Other Pages</option> 
     <option value = "index.html" >Home</option> 
     <option value = "faculty.html" >Faculty</option> 
     <option value= "survey.html" >Survey</option> 
     <option value= "positions.html" >Jobs</option> 
     </select> 
    </p> 
    </div> 
</div> 
+0

php를 사용하려면 확장자는'* .php' 여야합니다. – aldanux

+0

'header.php '의 잘못된 점을 볼 수있는 유일한 방법은'p'에서'h1'을 중첩시키는 것입니다. 둘 다 인라인 요소 만 허용 할 수 있으며 둘 다 블록 요소입니다. – MisterBla

답변

1

서버는 바로 브라우저로 코드를 전송 . .php 확장자 인 경우 서버는 PHP 코드를 처리하는 방법을 알고 있습니다. 이 설명을 살펴보십시오. HTML 파일은 .PHP 파일 확장자가 제공되지 않은 경우 서버에서 분석 할 수 없습니다 PHP 코드 세그먼트가 포함되어 있기 때문에 http://php.about.com/od/advancedphp/p/html_php.htm

+0

링크에는 .html 파일이 설정된 파일 인 경우 .htaccess 파일을 변경하는 방법이 나와 있습니다. <파일 yourpage.html> AddType application/x-httpd-php .html –

+0

이들은 로컬 HTML 파일이며 내가 아는 한 "서버"는 "QuickPHP"입니다. .htaccess 파일. HTML 파일을 PHP 파일로 변경 한 경우 큰 따옴표를 "작은 따옴표로 묶어야"합니까? – Torre

+0

.htaccess 파일은 보이지 않는 파일입니다 (파일 이름 앞에 점이 표시됩니다). 파일에 액세스하고 있지만 호스팅 서버의 관리자 패널로 이동하여 보이지 않는 파일을 볼 수 있습니다.없는 경우 원하는 내용을 입력하고 .htaccess로 저장하면 쉽게 만들 수 있습니다 (이것은 .htaccess.txt 또는 .htaccess가 아닌 정확한 파일명입니다.) –

0

HTML 파일도 PHP 파일이어야합니다. 나는 너의 문제가 해결 될 것을 기대한다. 이 태그와 아무것도 더 많은 것으로 간주되기 때문에 당신은 PHP 코드에서 오류를 명시하지 않습니다 사용개발자 도구가 <?php require'header.php'; ?>를 세그먼트간에

. 희망이 도움이 될 것입니다.

관련 문제