PHP4 -> PHP5: require does not check file directory anymore?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Markus Ernst

    PHP4 -> PHP5: require does not check file directory anymore?

    Hi

    In my application I have lots of require statements that include files
    residing in the same directory:

    index.php requires:
    require_once($_ SERVER['DOCUMENT_ROOT']."/modules/cms/classes/page.php");

    page.php requires:
    require_once("c ommon_functions .php");

    Now I try to install the application on a PHP5 server (Apache), and this
    does not work anymore.

    In the PHP4 -> PHP5 migration chapter of the manual I did not find any
    notes on a change of the require/include behaviour, not checking the
    directory of the calling file anymore; nor did I find it googling. So I
    am not sure if it is an undocumented migration issue or just a setting.

    I understand that I can use:
    require_once(di rname(__FILE__) ."/common_function s.php");

    But this means rewriting the whole application. Is there a way to change
    this behaviour via ini_set()? (As I am in a shared hosting environment I
    have no direct access to the php.ini.)

    Thanks for hints
    Markus
  • Jari Jokinen

    #2
    Re: PHP4 -> PHP5: require does not check file directory anymore?

    In comp.lang.php Markus Ernst <derernst@no#sp #amgmx.ch> wrote:
    [color=blue]
    > In the PHP4 -> PHP5 migration chapter of the manual I did not find any
    > notes on a change of the require/include behaviour, not checking the
    > directory of the calling file anymore; nor did I find it googling.[/color]

    Maybe your PHP5 configuration file doesn't set same include_path option
    than PHP4? You can add current directory (.) to include_path with this:

    set_include_pat h(get_include_p ath() . PATH_SEPARATOR . '.');

    --
    Jari Jokinen
    jari.jokinen@ik i.fi

    Comment

    • Markus Ernst

      #3
      Re: PHP4 -&gt; PHP5: require does not check file directory anymore?

      Jari Jokinen schrieb:[color=blue]
      > set_include_pat h(get_include_p ath() . PATH_SEPARATOR . '.');
      >[/color]

      Thank you, I tried this, but then it turned out to be something trivial:
      there was an open_basedir restriction on the PEAR include path.

      Though there was no including of a PEAR file at all, PHP seems to check
      the include path directories and output an open_basedir error before
      checking the directory the file resides in.

      I am not quite sure about where this behaviour is set - anyway if this
      is a new behaviour of PHP5 it should IMO be documented.

      Markus

      Comment

      Working...