I am trying to dynamically include a file based on what folder the file that is calling it is in. For instance:
The file www.whatever.com/abc/index.php would include the file:
www.whatever.com/template/abc.php and the file
www.whatever.com/xyz/index.php would include the file:
www.whatever.com/template/xyz.php
Does this make sense, oh gurus? I would appreciate your help!
Sure that makes sense. You want the name of script's parent directory. You will use that to build the path to the include file.
Here's test script:
<?php
// get the full url to the script $script_name = $_SERVER['SCRIPT_NAME']; echo "script_name -> $script_name <br>";
// split the url into an array of it's parts
$parts = explode('/', $script_name);// the second to last member of the $parts array is the parent directory $parent_dir = $parts[count($parts)-2]; echo "parent directory -> $parent_dir <br>";
?>
There are other ways to do this but this will work. You might want to add some error checking and make sure $parts has at least two elements.
Sheila -- Sheila Fenelon http://www.shefen.com/
____ � The WDVL Discussion List from WDVL.COM � ____
To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED] Send Your Posts To: [EMAIL PROTECTED]
To set a personal password send an email to [EMAIL PROTECTED] with the words: "set WDVLTALK pw=yourpassword" in the body of the email.
To change subscription settings to the wdvltalk digest version:
http://wdvl.internet.com/WDVL/Forum/#sub
________________ http://www.wdvl.com _______________________
You are currently subscribed to wdvltalk as: [EMAIL PROTECTED] To unsubscribe send a blank email to [EMAIL PROTECTED]
To unsubscribe via postal mail, please contact us at: Jupitermedia Corp. Attn: Discussion List Management 475 Park Avenue South New York, NY 10016
Please include the email address which you have been contacted with.
