I am quite frustrated with php’s include, as I have spent a ton of
time on it already... anyone can tell me why it was designed like this
(or something I don’t get)?
The path in include is relative NOT to the immediate script that is
including it, but is relative to the top-level calling script.
In practice, this means that you have to constantly worry and adjust
paths in includes, based on the startup scripts that call these
lower-level scripts.
Why is the include path not simply relative to the script that is
immediately including?
-- http://www.dbForumz.com/ This article was posted by author's request
Articles individually checked for conformance to usenet standards
Topic URL: http://www.dbForumz.com/PHP-Frustrat...ict132935.html
Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbForumz.com/eform.php?p=443884 43 5068
steve wrote: I am quite frustrated with php’s include, as I have spent a ton of time on it already... anyone can tell me why it was designed like this (or something I don’t get)?
The path in include is relative NOT to the immediate script that is including it, but is relative to the top-level calling script.
In practice, this means that you have to constantly worry and adjust paths in includes, based on the startup scripts that call these lower-level scripts.
Why is the include path not simply relative to the script that is immediately including?
You can always give the full path, in which case you don't have to worry about
things.
As I have understod, the include in PHP works more like a merge.
//Aho
steve wrote: I am quite frustrated with php’s include, as I have spent a ton of time on it already... anyone can tell me why it was designed like this (or something I don’t get)?
The path in include is relative NOT to the immediate script that is including it, but is relative to the top-level calling script.
In practice, this means that you have to constantly worry and adjust paths in includes, based on the startup scripts that call these lower-level scripts.
Why is the include path not simply relative to the script that is immediately including?
You can set your include path in your script anyway. So you can include
relative to any of your most common include paths...
"neur0mania k" wrote: steve wrote: I am quite frustrated with php’s include, as I have spent a ton
of time on it already... anyone can tell me why it was designed like this (or something I don’t get)?
The path in include is relative NOT to the immediate script that
is including it, but is relative to the top-level calling script.
In practice, this means that you have to constantly worry and
adjust paths in includes, based on the startup scripts that call these lower-level scripts.
Why is the include path not simply relative to the script that is immediately including?
You can set your include path in your script anyway. So you can include relative to any of your most common include paths...
J.O. and neur0maniak,
Thanks for your responses. While it can be managed, it is still a
huge maintenance pain. I am hoping that some php developers would
respond as to why not make script inclusion simply relative to the
including script, avoiding all the maintenance problems.
-- http://www.dbForumz.com/ This article was posted by author's request
Articles individually checked for conformance to usenet standards
Topic URL: http://www.dbForumz.com/PHP-Frustrat...ict132935.html
Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbForumz.com/eform.php?p=443945
On Sat, 24 Jul 2004 22:15:22 +0100, neur0maniak
<us****@neur0ma niak.co.uk> wrote: steve wrote: I am quite frustrated with php’s include, as I have spent a ton of time on it already... anyone can tell me why it was designed like this (or something I don’t get)?
The path in include is relative NOT to the immediate script that is including it, but is relative to the top-level calling script.
In practice, this means that you have to constantly worry and adjust paths in includes, based on the startup scripts that call these lower-level scripts.
Why is the include path not simply relative to the script that is immediately including?
You can set your include path in your script anyway. So you can include relative to any of your most common include paths...
What I like to do, and YMMV on your server, is to create an .htaccess
file containing at least one line:
php_value include_path "/full/path/to/my/includes"
You can of course append more than one search path with a colon (:),
but the point is to tell PHP where you plan on keeping your files to
include.
Then, no matter what file you do an include from, no matter where that
file resides, if you use simply:
include("myincl ude.php");
And myinclude.php is in /full/path/to/my/includes, then it will be
included flawlessly (provided no script errors on your part).
Even if you can't use .htaccess, you can create a header file to work
around this, somewhat to the effect of:
header.php:
<?
// Fill these out to your specs:
$system = ini_get("includ e_path");
$include = "/path/to/include:/more/search";
// Each file you wish to include:
$include_files = array(
"file1.php" ,
"file2.php" ,
"file3.php"
);
ini_set("includ e_path", $system . ":" . $include);
foreach ($include_files as $file)
{
include("$file" );
}
?>
This is untested, but maybe you get the idea for something you can do
on your own... good luck.
eclipsboi <ec*******@hotm ail.com> wrote in
news:e4******** *************** *********@4ax.c om: On Sat, 24 Jul 2004 22:15:22 +0100, neur0maniak <us****@neur0ma niak.co.uk> wrote:
steve wrote: I am quite frustrated with php’s include, as I have spent a ton of time on it already... anyone can tell me why it was designed like this (or something I don’t get)?
The path in include is relative NOT to the immediate script that is including it, but is relative to the top-level calling script.
In practice, this means that you have to constantly worry and adjust paths in includes, based on the startup scripts that call these lower-level scripts.
Why is the include path not simply relative to the script that is immediately including?
You can set your include path in your script anyway. So you can include relative to any of your most common include paths...
What I like to do, and YMMV on your server, is to create an .htaccess file containing at least one line:
php_value include_path "/full/path/to/my/includes"
You can of course append more than one search path with a colon (:), but the point is to tell PHP where you plan on keeping your files to include.
Then, no matter what file you do an include from, no matter where that file resides, if you use simply:
include("myincl ude.php");
And myinclude.php is in /full/path/to/my/includes, then it will be included flawlessly (provided no script errors on your part).
I like your .htaccess entry, but how does it impact performance of the
webserver or delay of processing php scripts?
Have you notice and degradation in performance?
--
Edward Alfert http://www.rootmode.com/
Multiple Domain Hosting and Reseller Hosting Plans
Coupon Code (Recurring $5/month Discount): newsgroup
"Edward Alfert" wrote: eclipsboi <ec*******@hotm ail.com> wrote in news:e4******** *************** *********@4ax.c om:
On Sat, 24 Jul 2004 22:15:22 +0100, neur0maniak <us****@neur0ma niak.co.uk> wrote:
steve wrote: I am quite frustrated with php’s include, as I have spent a ton of time on it already... anyone can tell me why it was designed like this (or something I don’t get)?
The path in include is relative NOT to the immediate script that is including it, but is relative to the top-level calling script. In practice, this means that you have to constantly worry and adjust paths in includes, based on the startup scripts that call these lower-level scripts.
Why is the include path not simply relative to the script that is immediately including?
You can set your include path in your script anyway. So you can includerelative to any of your most common include paths... What I like to do, and YMMV on your server, is to create an .htaccess file containing at least one line:
php_value include_path "/full/path/to/my/includes"
You can of course append more than one search path with a colon (, but the point is to tell PHP where you plan on keeping your files to include.
Then, no matter what file you do an include from, no matter where that file resides, if you use simply:
include("myincl ude.php");
And myinclude.php is in /full/path/to/my/includes, then it will be included flawlessly (provided no script errors on your part).
I like your .htaccess entry, but how does it impact performance of
the webserver or delay of processing php scripts?
Have you notice and degradation in performance?
This would work as long as the included filename is unique. If one
has 4-5 files called index.php in different directories, then the
solution would not work.
-- http://www.dbForumz.com/ This article was posted by author's request
Articles individually checked for conformance to usenet standards
Topic URL: http://www.dbForumz.com/PHP-Frustrat...ict132935.html
Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbForumz.com/eform.php?p=443980
steve <Us************ @dbForumz.com> wrote in
news:10******** *****@news.supe rnews.com: "Edward Alfert" wrote: eclipsboi <ec*******@hotm ail.com> wrote in news:e4******** *************** *********@4ax.c om:
On Sat, 24 Jul 2004 22:15:22 +0100, neur0maniak <us****@neur0ma niak.co.uk> wrote:
>steve wrote: >> I am quite frustrated with php’s include, as I have spent a ton of>> time on it already... anyone can tell me why it was designed like this>> (or something I don’t get)? >> >> The path in include is relative NOT to the immediate script that is>> including it, but is relative to the top-level calling script.>> >> In practice, this means that you have to constantly worry and adjust>> paths in includes, based on the startup scripts that call these>> lower-level scripts. >> >> Why is the include path not simply relative to the script that is>> immediately including? >> > >You can set your include path in your script anyway. So you can include>relative to any of your most common include paths...
What I like to do, and YMMV on your server, is to create an .htaccess file containing at least one line:
php_value include_path "/full/path/to/my/includes"
You can of course append more than one search path with a colon (, but the point is to tell PHP where you plan on keeping your files to include.
Then, no matter what file you do an include from, no matter where that file resides, if you use simply:
include("myincl ude.php");
And myinclude.php is in /full/path/to/my/includes, then it will be included flawlessly (provided no script errors on your part).
I like your .htaccess entry, but how does it impact performance of the webserver or delay of processing php scripts?
Have you notice and degradation in performance?
This would work as long as the included filename is unique. If one has 4-5 files called index.php in different directories, then the solution would not work.
Good point...
In that scenario I assume it would retrieve the first matching file in
the order that they paths are listed.
--
Edward Alfert http://www.rootmode.com/
Multiple Domain Hosting and Reseller Hosting Plans
Coupon Code (Recurring $5/month Discount): newsgroup
On 24 Jul 2004 22:49:10 GMT, Edward Alfert <ea*****@rootmo de.com>
wrote: I like your .htaccess entry, but how does it impact performance of the webserver or delay of processing php scripts?
Have you notice and degradation in performance?
I've never seen any impact to performance, as it's not doing enough to
impact it at all. I use a combination of include_path,
auto_prepend_fi le to limit the time I spend with includes. The
auto_prepend_fi le is as it sounds, it auto includes one file for every
script that's called from under the .htaccess. I put all my global
stuff in that file and work from there--I will never do it any other
way.
On Sat, 24 Jul 2004 23:00:02 -0000, steve
<Us************ @dbForumz.com> wrote: This would work as long as the included filename is unique. If one has 4-5 files called index.php in different directories, then the solution would not work.
I think you're missing the point of what it does. Of course you can't
have more than one file called the same thing, so you would change how
you name your files. Personally, I name my files based on what they
do:
mysql.inc
functions.inc
classes.inc
cart.inc
etc...
And before you mention about .inc files being sent to the web browser
as plain text, check out this solution you can put in your .htaccess:
<FilesMatch "inc">
Order deny,allow
Deny from all
</FilesMatch>
If you had more than one extension you didn't want people viewing in
their browser, you can change it to:
<FilesMatch "(inc|tpl|ext)" >
And when a user tries to view your .inc (or whatever) file, they get
an access forbidden message.
Sometimes when embracing an outside change, you have to look inside
yourself for some change also. If you absolutely need to keep your
files with the same names, try creating wrappers for them:
<?
include("/path/to/index.php");
?>
I do this on rare occasions, mostly for the sake of SEO, but the point
is it works, with very little to no impact on performance. I also use
symlinks, but I understand that Windows users don't have that option.
So wrappers is a universally Good Idea(TM) IMPO.
It's spiffy, really; give it a try, you might like it. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: steve |
last post by:
Hi,
I need to do conditional script "include", but like to pull the code
from db instead of a file. How do I do that?
Reason: I like to implement some complex regex logic, and make it
table driven. The regex would include if/then/else type logic, and
would like my script to conditionally execute the logic.
--
http://www.dbForumz.com/...
|
by: martijn |
last post by:
H!
I'm trying to find a python function to use like this:
-- maincode.py
Include "apythonscript_function.py"
-- end
|
by: Steven Borrelli |
last post by:
Hello,
I am using the <?php include() ?statement on my website for
organizational purposes. However, one of my includes contains some
PHP code. Is there any way for the server to actually parse the
include? I've tried this before, and it did not parse the include.
Rather, it included the file as just plain ASCII.
=======================...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
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: 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: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
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: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |