You are here: Re: Managing includes « HTML « IT news, forums, messages
Re: Managing includes

Posted by Disco Octopus on 06/27/07 09:51

dorayme wrote:
> For almost all of the sites I maintain, I am decking them out
> with PHP includes, some are operating fine outside on external
> servers. There is no management problem for this majority because
> of the portability of the construction I am using:
>
> ($_SERVER['DOCUMENT_ROOT'].'/site/includes/section.inc'); ?>
>
> Works beaut on both external and my local apache Mac server.
>
> But, now that I have the solution to a global construction for a
> Windows server for a couple of my sites (courtesy of help here in
> a recent thread), I am going to have a slight management problem.
> Because the construction used for these servers is double dutch
> to my Mac server.
>
> <? include "e:\inetpub\abc12345\includes\section.inc"; ?>
>
> my solution so far is to put both constructions of the includes
> on the files with one of them commented out for use here on my
> server (for testing) and the other commented out for upload to
> the actual server delivering the company site to the internet.
> This is obviously easy to do for just a few files. And for the
> business of uploading the newly "decked out with includes" whole
> site, I guess I can just use S&R (on the whole site) to switch it
> back and forth.
>
> Anyone got any better idea of how to do this? It's surely not
> that bad what I propose but I have this instinct that there are
> likely smarter way of proceeding.
>
Hi,

In your php.ini file, or you .htaccess file, or your httpd.conf file,
you have a include setting...

This would be unique to the server. So you only really need to enter
your include like this....

<? include "section.inc"; ?>

You should look into the "include_path" setting in php.

*or*, you could do something like this.... (but then, you may need to
include this chunk of code into its own included thing???)


<?php
$GLocalDev1 = 'l-mylocallinuxserver.com';
$GLocalDev2 = 'l-mylocalmacserver.com';
$GLocalDev3 = 'l-mylocalpcserver.com';
$GLive = 'live-site.example.com.au';
if ($_SERVER['HTTP_HOST'] == $GLocalDev1){
$IncludePath = "e:/inetpub/abc12345/includes/";
}
elseif ($_SERVER['HTTP_HOST'] == $GLocalDev2){
$IncludePath = "/home/www/mywebsite/includes/";
}
elseif ($_SERVER['HTTP_HOST'] == $GLocalDev3){
$IncludePath = "/whatever/your/mac/path/is/includes/";
}
include $IncludePath . "section.inc";
?>

--
Disco Octopus
www.choicebeefjerky.com.au

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация