PHP doesn't work

I have researched blogs and forums so much and cannot find a solution to this problem. I am using the Wamp directory: C: \ wamp \ bin \ apache \ apache2.4.9 \ htdocs \ lr

The lr at the end of / htdocs is just the folder where I store my webpage.

Code inside my index.php:

<?php include('includes/head.php'); ?>
    <?php include 'includes/header.php'; ?>
    <div id="container">
        <?php include 'includes/aside.php'; ?>
        &copy; 2011. All rights reserved.


When I load index.php in chrome or any browser, the only thing I see is the footer, which turns out to be the only thing that is NOT configured in the php include tag.

Here is the code inside my head.php

<title>Website Title</title>
<meta charset="UTF-8">
<link rel="stylesheet" href="css/screen.css">


Very simple code that only scares me why it doesn't work. If you would like more examples of the code that I am using, let me know. I am happy to provide some as I really need it in order to continue building the database for my registration / registration page.


source to share

3 answers

PHP probably doesn't find any files to include.

Are you sure the "includes" folder is in the same directory as index.php?

Also, I would suggest using "** / ** includes / ..." with a forward slash at the beginning to make sure it is looking for included files from the root directory and not from the relative path of your index.php.

Also, shouldn't your root be C: \ wamp \ www \ in WAMP?



Try to close the main tag first in your head, include the file, if that doesn't work, I'll dig deeper: D

Sometimes there are file path problems. I usually use:

<?php include $_SERVER['DOCUMENT_ROOT']."/filename.php";?>


In your case, it would probably be:

<?php include $_SERVER['DOCUMENT_ROOT']."/lr/includes/header.php";?>




You can check if the included file exists, this might let you know what is going on

    include 'includes/head.php';
   echo 'file either not readible or does not exist';




All Articles