FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » can't get includes to load
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: can't get includes to load [message #180921 is a reply to message #180920] Tue, 26 March 2013 08:36 Go to previous messageGo to previous message
J.O. Aho is currently offline  J.O. Aho
Messages: 194
Registered: September 2010
Karma:
Senior Member
On 26/03/13 07:52, Cal Dershowitz wrote:
> $ pwd
> /home/sites/migrate
> $ ls -l
> total 168
> ...
> drwxr-xr-x 2 fred automation 4096 Mar 25 23:03 includes
> -rw-r--r-- 1 fred automation 2208 Mar 25 23:32 index.html
> ...
> -rw-r--r-- 1 fred automation 896 Mar 25 21:49 style.css
> ...
> drwxr-xr-x 2 fred automation 4096 Mar 25 21:56 variables
> $ cd includes/
> $ ls -l
> total 20
> -rw-r--r-- 1 fred automation 88 Mar 25 23:03 footer.php
> -rw-r--r-- 1 fred automation 106 Mar 25 23:02 footer.php~
> -rw-r--r-- 1 fred automation 99 Mar 25 22:08 header.php
> -rw-r--r-- 1 fred automation 0 Mar 25 21:57 header.php~
> -rw-r--r-- 1 fred automation 141 Mar 25 22:15 nav.php
> -rw-r--r-- 1 fred automation 0 Mar 25 21:59 nav.php~
> -rw-r--r-- 1 fred automation 638 Mar 25 22:16 sidebar.php
> -rw-r--r-- 1 fred automation 0 Mar 25 22:00 sidebar.php~
> $ cd ..
> $ cat index.html
> <?php include('includes/header.php'); ?>
> <?php include('includes/nav.php'); ?>
> <?php include('includes/sidebar.php'); ?>
> <?php include('includes/footer.php'); ?>

From the file layout, it looks correct, we do recommend you use
$_SERVER['DOCUMENT_ROOT'] for includes eg:

include $_SERVER['DOCUMENT_ROOT'].'includes/sidebar.php';

this will make it easier the day when you put things in sub folders,
like /home/sites/migrate/articles and you still want to include those
from /home/sites/migrate/include.


> Right now, index.html loads but none of the other and it exits without
> complaint. This is only running on my linux machine here at the local
> root directory, which is indicated by the pwd command.

You have an index.html, when apache looks at the file it will think of
it as plain html and just output it as it is, you can easily verify this
by looking at the source code in the browser (right click on the page
and select "View Page Source"), you will see those <?php ?> tags.

The fix is to do a:

mv /home/sites/migrate/index.html /home/sites/migrate/index.php

now apache will use the php engine to parse the file and php engine will
replace the <?php ?> with the content in the files.

Sure there are some people who would say to add html to the AddHandler
for php, but please do not listen to them, you will make your apache/php
to work more and you will not be compliant with most hosting companies,
so when you upload your things to your web hotel you want it to work.

--

//Aho
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: mysql dynamic binding and pass-by-ref deprecated
Next Topic: Java conferences in India...
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Nov 13 07:05:29 GMT 2024

Total time taken to generate the page: 0.04684 seconds