简体   繁体   中英

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.

However, 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:

<?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. If I move the include header ABOVE the echo, then nothing shows up. If I have it below (like it is in the code above), the echo commands work, but everything stops after the include header.

There are no errors that I can seem to find, no warnings, no nothing...just not outputting anything past that specific include.

(Working with Microsoft WebMatrix if that is even remotely relevant)

This might be a shot in the dark but in general it's best practice to leave the closing ?> off of php-files. I don't see how that could affect including a file, but I also don't see anything else "wrong" with your code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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