trouble with include files

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • laredotornado@zipmail.com

    trouble with include files

    Hi,

    Here's my files and directories ...

    util_fns.inc
    hello.php
    mirror_site/util_fns.inc
    mirror_site/hello.php

    On hello.php, I have the line

    require("util_f ns.inc");

    However, I would like the behavior to be that the included file is the
    one that lives at the same level as "hello.php" . I'm noticing that the
    "mirror_sit e/hello.php" file is including the "util_fns.i nc" top level
    file when I want it to include the "mirror_sit e/util_fns.inc" file.
    How can I enforce this behavior?

    I would prefer not to create two separate hello.php files.

    Thanks for any assistance. Using PHP 4.3 if that is useful, - Dave

  • Marshall

    #2
    Re: trouble with include files

    Try to set the actual directory to a variable. Something like:

    $dir = getcwd();

    and then use:

    require($dir.'/hello.php');

    Something like this would work.

    Ah, by the way, don't let the extension be '.inc', put it with '.php'
    in the end, if someone access your file in the browser, the browser
    will display it as plain text letting everyone see your script.

    Comment

    • Dikkie Dik

      #3
      Re: trouble with include files

      Try:
      require(dirname (__FILE__) . '/util_fns.inc');

      laredotornado@z ipmail.com wrote:
      Hi,
      >
      Here's my files and directories ...
      >
      util_fns.inc
      hello.php
      mirror_site/util_fns.inc
      mirror_site/hello.php
      >
      On hello.php, I have the line
      >
      require("util_f ns.inc");
      >
      However, I would like the behavior to be that the included file is the
      one that lives at the same level as "hello.php" . I'm noticing that the
      "mirror_sit e/hello.php" file is including the "util_fns.i nc" top level
      file when I want it to include the "mirror_sit e/util_fns.inc" file.
      How can I enforce this behavior?
      >
      I would prefer not to create two separate hello.php files.
      >
      Thanks for any assistance. Using PHP 4.3 if that is useful, - Dave
      >

      Comment

      Working...