For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > August 2005 > include directive









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author include directive
Martin A. Weinberger

2005-08-10, 10:00 pm

Hi all,

I'm using the "include_once" directive in a PHP file, although I could be
using any of the other variants. My problem is that PHP doesn't like the
following code:

=========
Doesn't Work
=========
include_once( "/Folder/File.php" );

but if I do the following than it does.

=====
Works
=====
include_once( "./Folder/File.php" );

Is there any way to use the absolute path from the beginning of the domain?
HTML doesn't have a problem with absolutes, but PHP does.

Thanks in advance,

--
Martin A. Weinberger
ButterflyVista
http://www.butterflyvista.com/


Martin A. Weinberger

2005-08-11, 3:59 am

I guess I solved my own problem by using an include path, which does accept
absolute paths. I guess that was the intended approach, when the authors of
PHP made the restriction. I guess the question is now why the restriction.


--
Martin A. Weinberger
ButterflyVista
http://www.butterflyvista.com/


Veikko Mäkinen

2005-08-11, 3:59 am

Martin A. Weinberger wrote:
> Hi all,
>
> I'm using the "include_once" directive in a PHP file, although I could be
> using any of the other variants. My problem is that PHP doesn't like the
> following code:
>
> =========
> Doesn't Work
> =========
> include_once( "/Folder/File.php" );


This path tries to find a directory called Folder from the *filesystem*
root. It works just as well if you really have such a directory there
(and rights to use it). Just remove the first slash and make sure your
include path has all the right entries.


> include_once( "./Folder/File.php" );


This path points to a directory Folder in a current directory
(presumably the directory where executing php script lays).

> Is there any way to use the absolute path from the beginning of the domain?
> HTML doesn't have a problem with absolutes, but PHP does.


When you use absolute paths in HTML, they point to the root of your
website (eg. href="/index.html" in www.example.com/foo/bar/foo.html
points to www.example.com/index.html). Generally all paths in php work
with *filesystem*.


-veikko

--
veikko
mail@ .com
makinen
Martin A. Weinberger

2005-08-13, 3:59 am

Thanks Veikko.

--
Martin A. Weinberger
ButterflyVista
http://www.butterflyvista.com/


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com