Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Moderated Pro PHP
|
Moderated Pro PHP This is a moderated forum for discussing advanced, professional level issues with PHP. Your posts will not appear until a moderator approves them. Posts that are not the right level for this forum will be responded to and you'll be asked to post them in the [url="http://p2p.wrox.com/sql-server-2000-20/9"]Beginning PHP[/url] forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Moderated Pro PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 10th, 2005, 02:26 PM
Registered User
 
Join Date: Jun 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default site-relative path for includes

In php.ini, the include_path, you can specify

1) the fully qualified path to the includes folder

or

2) a path beginning with a ".", indicating that the path is relative to the page.


But what if I want to specify a path relative to the site root? Well, I could just put the fully path to the site root in my include_path, sure. But what if I have more than one web site on my server, and then have similarly named includes, e.g. "header.php"?

Thanks.

 
Old July 25th, 2005, 12:37 PM
Registered User
 
Join Date: Jun 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The option I use for your question is to use a global variable or constant defined with the path to the folder housing all your include documents, as well as a variable defining the path to your site root. This way as long as they are both defined correctly, you can always code to you $site_fs_dir/$include_dir for your include paths.

Josh Todd
Inquis Technologies, LLC
http://www.inquistech.com
 
Old July 25th, 2005, 12:58 PM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

I'd set it dynamically.

//Assuming a *nix style include_path
ini_set('include_path', '.:'.$_SERVER['DOCUMENT_ROOT']);

I wonder if you could do this in Apache httpd.conf or .htaccess (after DOCUMENT_ROOT is set).
php_value include_path .:%{DOCUMENT_ROOT}

Not sure if that would work. I know that works for other things. Might be one of those values that must be quoted, not sure what syntax to use for concatenation, or even if there is any.

You could include the former runtime set as an appended script, if necessary, via the auto_append_file / prepend directives.

Regards,
Rich

--
[http://www.smilingsouls.net]
Mail_IMAP: A PHP/C-Client/PEAR solution for webmail
Author: Beginning CSS: Cascading Style Sheets For Web Design





Similar Threads
Thread Thread Starter Forum Replies Last Post
Relative and Absolute Path question Johnger Pro Visual Basic 2005 1 September 8th, 2006 10:45 AM
iis cannot find images in relative path vhrao ASP.NET 1.x and 2.0 Application Design 4 November 30th, 2004 11:00 AM
Relative Path Connection String fangai Classic ASP Databases 1 October 3rd, 2003 02:37 AM
LDAP and Relative Path problem Dmitriy Pro VB 6 0 July 21st, 2003 12:45 PM
DeleteFile(filespec) with relative path? brandon1974 Classic ASP Basics 1 July 19th, 2003 04:58 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.