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. 3 6923
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.
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 ra****@satyam.n et.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/ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 we've got is that our way to
include some files in other ones is no more working properly. The message we
are getting looks like: "PHP Warning:...
|
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, returning a Failed opening error. If I put in the full
path, it works just fine. Do site-based absolute paths not work in
|
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 session variable is set,
otherwise I stop executing and redirect.
My problem is that this works if I use a relative path to the include
file, but...
|
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 control sub webs more
tightly on my new host via virtual director and wish to improve the folder
structure and code on my various sites.
However,...
|
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 :
***************
consumer.php : <? include "inc.php" ?>
inc.php : <? include "Common/functions.php" ?>
| |
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 very carefully define the
order in which paths are searched with command line options
on the compiler. Both can cause problems, especially when...
|
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 to add around 70
additional include directories to the project's compiler settings.
Each of these paths is between 40 and 100 characters long (after...
|
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 code :
<?php
include("../inc/connect.php") ;
....
|
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" -->
<!-- #include virtual="/includes/file3.asp" -->
<!-- #include virtual="/includes/file4.asp" -->
<!-- #include virtual="/includes/file5.asp" -->
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |