PHP Server Paths (Probably OT)

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
On a Unix server, including the server on my Mac, you can use

<?php include ($_SERVER['DOCUMENT_ROOT'].'/includes/');

in any html doc at any level (at least at any level at or below
the normal /public_html) and the footer appears fine in any
browser and with the folder "includes" (containing the footer
markup) at almost any level.

In order to get php includes working on a Windows server, I
manage by stating the detailed path to the folder. This involves
more careful vetting of all the paths in the various folders and
sub folder. It would be nice to have some construction that
worked like with a Unix server. Any suggested strategies please?

(I post here rather than PHP ng because they seem altogether too
technical for it to be useful to me... though I might try. I
think I may have asked something similar in the past but the fact
is I am no nearer a solution. Just be a bit neater not to have to
vet all the paths...)


Re: PHP Server Paths (Probably OT)

On Fri, 16 Feb 2007 02:03:07 +0100, dorayme  

Quoted text here. Click to load it

As long as it's accessed by the web-server, $_SERVER['DOCUMENT_ROOT']  
should still work, I use it here on W2K all the time. If this does not  
work for you, what's the actual content of $_SERVER['DOCUMENT_ROOT'] if  
you echo it? And are you using Apache or ISS (or a totally different  

Quoted text here. Click to load it

Tsssk, did they bother you about the include_path directive or something?

Rik Wasmus

Re: PHP Server Paths (Probably OT)

Quoted text here. Click to load it

It would be lovely if it worked for me. because then, there would
be a perfect model on my own home Apache server for the setup at

Quoted text here. Click to load it

Optus say: "All Optus shared web servers are built on a
combination of Windows Server 2003 and Internet Information
Services 6.0 technology... blah blah"

The truth is that I want to work with it and have at least one or
two sites on Windows servers to gain experience and not get all
wobbly and persuade every client to change to Unix (and cheaper
plans usually!). The ky has not fallen in yet. I just would like
to be able to better model the includes business to be quite

What do you suggest i actually do in plain and strict algorithmic
manner to answer your echo question?

Don't laugh but I added a line toi an html doc that goes:

<?php echo $_SERVER['DOCUMENT_ROOT']; ?>

uploaded the doc to the Optus server and accessed the doc in a
browser and got:

"PHP Warning: main(/includes/ [function.main]: failed
to create stream: No such file or directory in
e:\inetpub\esvc000862\globalTest.html on line 13 PHP Warning:
main() [function.main]: Failed opening '/includes/' for
inclusion (include_path='.;e:\php') in
e:\inetpub\esvc000862\globalTest.html on line 13"

How do I suck on that?

Quoted text here. Click to load it

No, they are all very nice over there. It is painful letting new
people know how ignorant I am. With you lot, I hide nothing, no
amount of ill treatment deters me. You are a family I cling onto
for better or worse. It's horrible but what can I do? Where can I
go? I am like the battered wife with bad options. It is a total
disgrace but no one will blame me in the end.


Re: PHP Server Paths (Probably OT)

dorayme wrote:
Quoted text here. Click to load it

The problem comes from running PHP/CGI, the work around is to use ISAPI
instead of CGI. But that can be difficult to make a web hotel to change.



Re: PHP Server Paths (Probably OT)

On Fri, 16 Feb 2007 08:46:52 +0100, dorayme  =

Quoted text here. Click to load it

Well, it's like HTML/CSS questions, trim all unnecessary code. So make a=

file _only_ containing <?php print_r($_SERVER); ?>, and we'll know a lot=


A possible <?php phpinfo(); ?> reachable somewhere would help a lot too,=

then we can see most of the configuration.
-- =

Rik Wasmus

Re: PHP Server Paths (Probably OT)

Quoted text here. Click to load it

It will be exactly the same. The remark I quoted was in direct
response to the php line I thought you were suggesting. Trim what?

Quoted text here. Click to load it
Yes, there may be clues here. Anything in particular that is
important out of the masses of info in the panels that come up?

There is:

Windows NT localhost 5.2 build 3790

Server API
Virtual Directory Support
Configuration File (php.ini) Path

and, here is a snippet from something to do with includes, roots
I notice:

include_path Local Value is .;e:\php Master Value is .;e:\php

(looking at this stuff makes me want to go and have 5 double
bourbons in a row quickly...)


Re: PHP Server Paths (Probably OT)

dorayme wrote:

Quoted text here. Click to load it

Unless you're moving files about *a lot*, or you enjoy including files
that include files that include files... just use relative paths. Easy.

    <?php include './../../includes/'; ?>

Personally, I prefer to create an includes directory, put it wherever the
hell I like (perhaps even outside the document root!) and include files
like this:

    <?php include ''; ?>

So how does PHP know where is kept? By setting the
"include_path" setting in "php.ini", ".htaccess", "httpd.conf"
or similar. Of course, if you are on shared hosting, you may
need to check that it is possible for you to adjust the

Toby A Inkster BSc (Hons) ARCS
Contact Me ~
Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux

* = I'm getting there!

Re: PHP Server Paths (Probably OT)

Quoted text here. Click to load it

I don't and I don't.

Quoted text here. Click to load it

Which is exactly what I am doing on the Optus Windows server. But
not as easy as with the

<?php include ($_SERVER['DOCUMENT_ROOT'].'/includes/');

construction I use on my own server on this here machine nor on
other external Unix servers I maintain websites on.

As I understand it, this above construction relieves me of having
to work out the path to the includes folder on a per file basis.

The point of me wanting all this is not just to save a bit of
work but to be able to model the websites I have on Windows
servers on my own server here on the Mac. I get to keep one
website folder this way, not a number of them to suit different
Quoted text here. Click to load it

I am sort of following you here, the trouble is that I am a bit
lost over fine controls over the Windows servers concerned. They
are external and I do not _seem_ to have access to htaccess,
httpd.conf type thingies and before me is a horrible option,
having to ask Optus something and how the hell to phrase it and
let total strangers place me on an Andy Dingley scale of
cluelessness and get it wrong to boot. Even a martian has his


Re: PHP Server Paths (Probably OT)

dorayme wrote:
Quoted text here. Click to load it
  Use the ini_set() function to change the value of include_path. The
disadvantage is that the setting only lasts for the session.

  For a fully DIY method there is this. <> provides a set of
custom directory strings created at the start of a session:
  if (eregi('', $_SERVER['SERVER_NAME'])) { // Local copy?
    $base_dir1 =  'f:/pub/websites/';
    $base_dir2 = $base_dir1 . 'sma-improved/';
  else { // Must be the WWW
    $base_dir1 =  '/usr/local/apache/';
    $base_dir2 = $base_dir1 . 'htdocs/';
which is called by

  function globals_init ($start_path)
    global        // If they weren't global before, they are now.
    if (!isset($base_dir1)) {
      $val = $start_path . '';
      require($val);    // Assigns $base_dir1 ...,  here.
    // ...whatever else you want set up...

This must be at the top of every PHP page:

  The advantage is the option to create a number of base directory paths.
  It has its weaknesses, of course. The main being the need to prepend
base_dir1 (or base_dir2, ...) to the relative paths.

jmm (hyphen) list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email)

Site Timeline