Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #8857
| From | "J.O. Aho" <user@example.net> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: can't get includes to load |
| Date | 2013-03-26 09:36 +0100 |
| Message-ID | <ard4vmFub4uU1@mid.individual.net> (permalink) |
| References | <H4qdnb_BO5pZ2MzMnZ2dnUVZ_oOdnZ2d@supernews.com> |
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
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
can't get includes to load Cal Dershowitz <cal@example.invalid> - 2013-03-25 23:52 -0700
Re: can't get includes to load "J.O. Aho" <user@example.net> - 2013-03-26 09:36 +0100
Re: can't get includes to load Cal Dershowitz <cal@example.invalid> - 2013-03-26 14:50 -0700
Re: can't get includes to load Jim Higgins <ILikeMy@Privacy.bogus> - 2013-03-27 02:14 +0000
Re: can't get includes to load "J.O. Aho" <user@example.net> - 2013-03-27 07:53 +0100
Re: can't get includes to load Cal Dershowitz <cal@example.invalid> - 2013-03-27 02:35 -0700
Re: can't get includes to load "J.O. Aho" <user@example.net> - 2013-03-27 11:00 +0100
Re: can't get includes to load "J.O. Aho" <user@example.net> - 2013-03-27 11:03 +0100
Re: can't get includes to load Cal Dershowitz <cal@example.invalid> - 2013-03-28 00:17 -0700
Git (Was: can't get includes to load) "J.O. Aho" <user@example.net> - 2013-03-28 08:35 +0100
Re: can't get includes to load Cal Dershowitz <cal@example.invalid> - 2013-03-28 00:41 -0700
Git (Was: can't get includes to load) "J.O. Aho" <user@example.net> - 2013-03-28 09:34 +0100
Re: Git (Was: can't get includes to load) Cal Dershowitz <cal@example.invalid> - 2013-03-29 00:28 -0700
Re: Git (Was: can't get includes to load) "J.O. Aho" <user@example.net> - 2013-03-29 13:14 +0100
Re: Git (Was: can't get includes to load) Cal Dershowitz <cal@example.invalid> - 2013-03-31 00:31 -0700
Re: Git (Was: can't get includes to load) "J.O. Aho" <user@example.net> - 2013-03-31 11:54 +0200
cleaning up first php page was Re: can't get includes to load Cal Dershowitz <cal@example.invalid> - 2013-03-27 00:00 -0700
Re: cleaning up first php page was Re: can't get includes to load "J.O. Aho" <user@example.net> - 2013-03-27 09:06 +0100
Re: cleaning up first php page was Re: can't get includes to load Cal Dershowitz <cal@example.invalid> - 2013-04-04 01:48 -0700
Re: cleaning up first php page was Re: can't get includes to load Cal Dershowitz <cal@example.invalid> - 2013-04-04 01:52 -0700
Re: cleaning up first php page was Re: can't get includes to load Jerry Stuckle <jstucklex@attglobal.net> - 2013-04-04 08:57 -0400
Re: can't get includes to load Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-03-27 09:08 +0100
csiph-web