473,326 Members | 2,134 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

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.

Jul 17 '05 #1
3 6906
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.

Jul 17 '05 #2
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

Jul 17 '05 #3
ra****@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/

Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Yannick Turgeon | last post by:
Oups! I did a typing error in my last post. Fixed. ----------- Hello all, We are currently changing our web server and, in the process, updating PHP version from 4.3.0 to 4.3.5. The problem...
5
by: meredith | last post by:
I'm running Debian Linux stable and PHP 4.1.2. My include_path is '.:/php/includes:/usr/local/lib/php/:/usr/local/lib/php/smarty/' Problem is, include('/includes/foo.php'); doesn't work,...
2
by: Marcus | last post by:
Hello, I am having problems with an include statement. I'm setting a session variable flag and then including a file, and in that include file I have a check at the top to make sure that the...
0
by: jason | last post by:
What is the best way to handle global includes for 3 subwebs that may at various times consume similiar include files such as ENQUIRY FORMS. I ask this question as I now have the oppportunity to...
15
by: tom pester | last post by:
Hi, Im new to php and have a background in asp. All the help is very much appreciated. today I was using the include function in a file that itself gets included : ***************...
5
by: David Mathog | last post by:
One thing that can make porting C code from one platform to another miserable is #include. In particular, the need to either place the path to an included file within the #include statement or to...
3
by: Andreas Busse | last post by:
Hi, I received a big fat package of source code developed with Metrowerks CodeWarrior and now I am trying to convert this project to VC.NET 2003. My problem is, that in order to compile I have...
13
by: alex | last post by:
Hi, I've got a php script located at : http://localhost/browse/script.php This script is "URL-rewrited" as http://localhost/welcome.htm This script includes other scripts with the following...
10
by: Eric | last post by:
Hello, I have some server side includes on a Classic asp page that look something like: <!-- #include virtual="/includes/file1.asp"--> <!-- #include virtual="/includes/file2.asp" --> <!--...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.