PHP包含/要求无法正常工作

时间:2015-09-23 02:01:41

标签: php html

我目前正在开发一个网站,我正在尝试使用PHP include命令以递归方式将标题和菜单链接添加到每个页面。每当我尝试将特定的PHP文件作为包运行时,它都不会显示。当我按需要运行它时,页面加载空白。

经过一番研究,我找到了解决问题的最常见方法;确保index.php和您尝试包含的页面需要具有.php扩展名;他们这样做。

基本上我正在使用的是: 网站母版页是: www.humanistsofutah.org(或称为index.php) 主机是Xmission虚拟主机。 openbased_dir设置为/var/www/vhosts/humanistsofutah.org /

我正在为PHP代码引用的文件名为Houbodyphp.php

这是index.php代码:

     <!DOCTYPE HTML>
    <html>
    <head>
    <?php 
    $INC_DIR = $_SERVER["DOCUMENT_ROOT"]."/includes"; ?>
    <?php include($INC_DIR. "houbodyphp.php"); ?>

   <title>Humanists, Humanism, and Rational Thinking in Utah</title>
    <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">                                                </meta>
    <link href="houart.css" rel="stylesheet" type="text/css/php">


    <meta name="keywords" content="humanism, humanist, science, naturalism,      skepticism, non-theism, atheism, atheist, agnosticism, rational, rationalist, freethought, freethinker, scientific method">
    </head>
    <body> 
    <table border="0" cellspacing="0" cellpadding="0" width="97%" summary="Humanists of Utah (Border)"> 
    <tbody> 
     <tr> 
     <td width="20%"> 
    &nbsp;
        &nbsp;

这就是HouBodyphp.php代码的样子:

         <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
         <html>
         <head>
         <style>
          tbody {position: relative}
         </style>
          <body> 

                                                                         

             <table border="0" cellspacing="2" cellpadding="1" width="100%" summary="Humanists of Utah"> 
                 <tbody> 
                  <tr> 
                 <td align="center" colspan="6" width="50%"><a href="http://humanistsofutah.org/wordpress/"><img width="600" alt="" style="width: 600px;" src="picture_library/UtahbkgLogoCORRECT.png" /></a></td> 
                 </tr> 
                 <tr> 
                <td align="center" width="50%" colspan="6" rowspan="4" valign="middle" bgcolor="#ffffff" style="white-space: nowrap;"> 
            <div style="text-align: center;"><b><span style="font-family: Verdana; font-size: 9pt; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"><a href="http://humanistsofutah.org/wordpress/what-is-humanism/">What is Humanism?  </a>               <br /><br /></span></b> 
            </div> 
            <div style="text-align: center;"><span "="" background-size:="" background-origin:="" background-clip:="" background-position:="" background-repeat:="" initial;"="" style="font-family: Verdana; font-size: 9pt; background-image: initial;"><a href="http://humanistsofutah.org/wordpress/get-involved/upcoming-events/">Meeting Information and Contacts</a>&nbsp;-&nbsp;</span>          <span font-family:="verdana" ;="" font-size:="9pt" background-image:="" initial;="" background-attachment:="" background-size:="" background-origin:="" background-clip:="" background-position:="" background-repeat:="" initial;"=""><a style="font-family: Verdana; font-size: 9pt;" href="search.html">Search HoU Website</a>&nbsp;-&nbsp;</span> <span style="font-size: 9pt; font-family: Verdana;"><a href="http://humanistsofutah.org/wordpress/archivalsample/">Archive</a></span> <span style="font-family: Verdana; font-size: 9pt;">&nbsp;</span> 
            </div> 
            <p style="text-align: center;"><span style="font-size: 9pt; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"><a style="font-family: Verdana; font-size: 9pt;" href="http://humanistsofutah.org/wordpress/membership/our-members/">Our Members</a></span> <span style="font-family: Verdana; font-size: 9pt; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;">&nbsp;-&nbsp;<a href="http://humanistsofutah.org/wordpress/about-2/historical-humanists/">Historical Humanists</a></span> <span style="font-size: 9pt;">&nbsp;-&nbsp;</span><span style="font-family: Verdana; font-size: 9pt; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"><a style="font-size: 9pt;" href="http://humanistsofutah.org/wordpress/media/recommended-reading/">Recommended Reading</a></span></p> 
            <div style="text-align: center;"><a href="http://humanistsofutah.org/wordpress/related-websites/"><span style="font-family: Verdana; font-size: 9pt; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;">Our Favorite Websites</span></a>&nbsp;-&nbsp;<a href="http://humanistsofutah.org/wordpress/related-websites/"> <span style="font-family: Verdana; font-size: 9pt; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;">Links</span></a>&nbsp;-&nbsp;<span style="font-family: Verdana; font-size: 9pt; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"><a href="www.humanistsofutah.org/wordpress">Great Quotes</a></span> 
            </div> </td> 
        </tr> 
      </tbody> 
    </table></td> 

``      

我知道其中一些可能是完全错误的,并且我已经事先为此道歉,但我已经在这方面苦苦挣扎数周而且迫切需要帮助。

感谢您的时间,

Eric Whittaker

1 个答案:

答案 0 :(得分:1)

由于以下代码,您的PHP将尝试包含文件includeshoubodyphp.php

<?php include($INC_DIR. "houbodyphp.php"); ?>

在此处添加/

<?php include($INC_DIR. "/houbodyphp.php"); ?>