简体   繁体   English

PHP包含工作,没有包含标头

[英]PHP include working, include header is not

So I've tried looking around in other questions, but can't seem to find a question consistent with my problem. 因此,我尝试环顾其他问题,但似乎找不到与我的问题相符的问题。

What's going on is that I have been working on a project using angularjs, and primarily working on pure html for most of the development, and am finally at a stage where I want to cut out the header/footer code and bring it in as php with includes. 发生的事情是我一直在使用angularjs进行项目开发,并且在大部分开发中主要使用纯html进行工作,最后处于要切掉页眉/页脚代码并将其作为php引入的阶段与包括。

However, include("../Includes/header.php"); 但是,include(“ ../ Includes / header.php”); is not working. 不管用。 Other includes with basic code seems to be working okay. 其他包含基本代码的代码似乎工作正常。 Here's my code: 这是我的代码:

<?php 
    //require_once ("Includes/simplecms-config.php"); 
    //require_once  ("Includes/connectDB.php");
    include("./svg.php"); 
    include("../Includes/include.php");
    echo "<i>This is an echo from the current file.</i><br />";
    include("../Includes/header.php");
?>

This is the code from ../Includes/include.php: 这是来自../Includes/include.php的代码:

<?php
    echo "<b>This is an included echo from another directory.</b><br />";
?>

the .svg.php file is irrelevant, just some svg graphics I use. .svg.php文件无关紧要,只是我使用的一些svg图形。 If I move the include header ABOVE the echo, then nothing shows up. 如果将include标头移到回显上方,则不会显示任何内容。 If I have it below (like it is in the code above), the echo commands work, but everything stops after the include header. 如果我在下面有它(就像上面的代码中一样),则echo命令可以工作,但是一切都在include标头之后停止。

There are no errors that I can seem to find, no warnings, no nothing...just not outputting anything past that specific include. 我似乎没有发现任何错误,没有警告,没有任何东西……只是不输出超出特定include的任何内容。

(Working with Microsoft WebMatrix if that is even remotely relevant) (与Microsoft WebMatrix一起使用,即使它们与远程相关)

This might be a shot in the dark but in general it's best practice to leave the closing ?> off of php-files. 这可能是在黑暗中拍摄的照片,但一般而言,最好的做法是关闭结尾的?> php文件。 I don't see how that could affect including a file, but I also don't see anything else "wrong" with your code. 我看不到这会如何影响包括文件,但是我也看不到您的代码有任何其他“错误”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM