Re: climb up the path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Iv Ray wrote:
Jim Lucas wrote:
Iv,

tell me why you are wanting to do this?

If it is the reason I think it is, I can give you a better way to accomplish this.

I have the source and a configuration file, which I want outside the source - it is different from server to server.

The easiest is to have the configuration file one folder up.

In  the same time I want the source to work wherever it is placed.

So the source sees where it is, and climbs one directory up to read the configuration specific for this installation.

I do not want to use "ignore" in the repository, in order to prevent the configuration file from being overwritten.

Iv


So, saying that it is outside the source does not tell me if it is outside the document root.

So, I guess my option might still work in this case.

Use your include_path php_ini setting

if you have a main file that you include, like I have one that is called handy.php that is included at the top of every script.

In this main file, you could modify your include_path


#main_included_file.php
<?php

#if you are trying to go to the parent folder, then just ../
#but if you want to go to the parent/parent folder use ../../

ini_set('include_path', '../../;../;'.ini_get('include_path'));

#the rest of your stuff goes here.

?>

Then...

#yourscript.php
<?php

include_once 'main_include_file.php';

include 'config.php';

...

?>

This should work for any host.
--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
       and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
    by William Shakespeare


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux