include() and absolute path

This is a discussion on include() and absolute path within the PHP Language forums, part of the PHP Programming Forums category; I am setting up a website with a number of folders like: / (the document root) /user /admin/ /content in the /...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-22-2005
rajuvk@satyam.net.in
 
Posts: n/a
Default include() and absolute path

I am setting up a website with a number of folders like:
/ (the document root)
/user
/admin/
/content
in the /user folder there is a flie "userlogged.php", which I want to
include in every file. If in the file "/content/index.php", if I use
the relative path and place the include like this
"../user/userlogged.php", it will work fine. But when I use the
absolute path like "/user/userlogged.php", it is not working ?. I have
read in several posts that the absolute path will work with include().
( Or am I wrong ?)
can any body tell me how to enable the absolute path method ?. The
relative path method is fine but when going deep with many subfolders,
the path will be come lengthy with "../../" and is difficult to
maintain and is a problem when moving the pages around. using absolute
path is a remedy to this.

is there any other method/ function similar to include(), to place
content of a file in another file ?

thanks ina dvance.

Raju V.K.

Reply With Quote
  #2 (permalink)  
Old 04-22-2005
Taare
 
Posts: n/a
Default Re: include() and absolute path

When you use include("/mypath/myfile.php") it doesnt look in the path
relative to http://mysite.com/ but rather relative to your system root.
You can make a .htaccess file that looks like this:
php_flag include_path "/home/me/myphpfiles/:."

And do include("user/userlogged.php") and will then first look for
/home/me/myphpfiles/user/userlogged.php, if it's not found, it will be
looked for relative to the current path.

Reply With Quote
  #3 (permalink)  
Old 04-27-2005
rajuvk@satyam.net.in
 
Posts: n/a
Default Re: include() and absolute path

Does the PHP and HTML behave differently when it comes to paths ?. If
I give /user/userlogged.php as the address of a page in the <a></a>
tag, it will always loads the userlogged.php page from the /user
folder, from the document root of the web-site. (That is
http://mysite.com/user/userlogged.php). I wish to repeat this behaviour
in PHP include(). Irrespectice of the location of the file calling the
include function, the page userlogged.php shall be included. What is
the best way to achieve this ?

Regards,
Raju

Reply With Quote
  #4 (permalink)  
Old 04-28-2005
R. Rajesh Jeba Anbiah
 
Posts: n/a
Default Re: include() and absolute path

rajuvk@satyam.net.in wrote:
> Does the PHP and HTML behave differently when it comes to paths ?.

If
> I give /user/userlogged.php as the address of a page in the <a></a>
> tag, it will always loads the userlogged.php page from the /user
> folder, from the document root of the web-site. (That is
> http://mysite.com/user/userlogged.php). I wish to repeat this

behaviour
> in PHP include(). Irrespectice of the location of the file calling

the
> include function, the page userlogged.php shall be included. What is
> the best way to achieve this ?


I'm afraid, it is very hard to help you here--you seem to lack the
basic idea of filesystems. You definitely have to look at file system
basics and HTTP basics.

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 11:19 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0