Search code examples
phpincludeinternal-server-error

PHP unable to include other PHP files


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?


Solution

  • Try this:

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

    see: PHP include absolute path