skip to Main Content

I’ve playing with a very simple setup: index.php with a header.php in the same directory. I’ve tried all the ways to include the header.php into my index.php but I still get a 500 – Internal Server Error.

So I tried the most fool-proof method and only coded this into my index.php

<?php
include("http://mywebsite.com/header.php"); 
echo "index";
?>

Then in my header.php I only coded

<?php echo "header"; ?>

I cannot figure out whats causing the problem. I’ve included an absolute path to the header. When I remove the include function the 500 error is no longer an issue.

I’m running my site using GoDaddy with a Plesk/Windows platform if that makes any difference?

2

Answers


  1. Try this:

    <?php 
       $path = $_SERVER['DOCUMENT_ROOT'];
       $path .= "/header.php";
       include_once($path);
    ?>
    

    see: PHP include absolute path

    Login or Signup to reply.
  2. Try this:

    Contents of index.php:

    <?php 
    include 'header.php';
    echo 'index';
    ?>
    

    Contents of header.php:

    echo 'header';
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search