Jump to content

Immediate Help Needed: Variable path in include() wanted


JetJagger

Recommended Posts

I hope I explain this correctly:

 

For PHP 4.0

 

 

PRIMER:  I have includes throughout my site.  The function of my includes is to pull in content from '/bodyCopy' into construct pages (i.e., public pages).  The actual content files are named differently though they all sit in the same '/bodyCopy directory' (e.g., aboutus.php, faq.php, etc.).

 

Simple enough.

 

 

CHALLENGE:  As I create new sub-domains, I need to change the 'http' path UP UNTIL the '/bodyCopy' directory.  For example:

 

<?php include('http://subdomain.mywebsite.com/bodyCopy/filename.php') ?>

 

Whereas '/bodyCopy/filename.php' will always remain constant (though actual file names will be different), I need to be able to manually change 'http://subdomain.mywebsite.com' from a single 'control' file so that changes to the 'http' path cascade to all directories where my includes exist within the sub-domain.

 

In other words, because I have hundreds of these includes per sub-domain, I need a way to change all 'http' paths of them, UP UNTIL THE '/bodyCopy' directory, at one time.  I want to create ONE simple text file PER SUB-DOMAIN that contains nothing more than the 'http' path.  When changes are made to THAT file, the 'http' path change cascades throughout the sub-domain site.

 

 

SOLUTION NEEDED:  So, the construct of the include should look like this:

 

<?php include('text_file_containing_the_http_path+/bodyCopy/filename.php') ?>

 

To the browser, the include should look like:

 

<?php include('http://subdomain.mywebsite.com/bodyCopy/filename.php') ?>

 

 

Then, there should be a separate text file (.txt or .php) that contains the actual 'http' path (i.e., text_file_containing_the_http_path).  The contents of that file will simply be something like 'http://www.anydomain.com' and nothing else.

 

 

Now, I've probably "over-explained" my need here, but I've asked this question on other message boards and always gotten non-working solutions.  This seems like a very simple problem, but I can't seem to find it.  Immediate help is greatly appreciated.

 

 

Link to comment
Share on other sites

ohya... WAY over explained lol...

 

1) php is only EVER processed on the server... it never touches the browser in "any" way shape or form :P

2) the include() functions are always relative, unless otherwise specified... lol

<?php include('bodyCopy/filename.php') ?>

should work just fine...

3) if you want to use php variables inside a include()

<?php
$var='test/';
include($var.'bodyCopy/filename.php')
?>

would move the file search into the test/ directory

 

;D

 

hope that helps some?

 

Link to comment
Share on other sites

Kewl.  Thanks.  I know that was WAY too simple for most of you, but it certainly helps.  I appreciate it.

 

I also received some online help from my Webhost who said use:  'fopen' instead of 'include'.

 

All you PHP guys and gals rock!  Keep on coding!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.