problem with 'include' and 'file_exists' function

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • +86

    problem with 'include' and 'file_exists' function

    i encountered this problem:
    "include('inc.p hp')" will work problely
    but "include('./inc.php') doesn't work ..
    both file_exists('in c.php') or file_exists('./inc.php') didn't return
    the right value.this always show "file doesn't exists'

    my environment is win2003+iis+php 5

    how to fix it ?

    sorry to my English

    thanks to you.

    :)

  • Gordon Burditt

    #2
    Re: problem with 'include' and 'file_exists' function

    "include('inc.p hp')" will work problely
    >but "include('./inc.php') doesn't work ..
    There are plenty of situations where this will happen. If a file
    name begins with ./, it will be looked up with include_path relative
    only to the current working directory, not the current script.

    Are you SURE you know what the current working directory is when
    the script is started?
    >both file_exists('in c.php') or file_exists('./inc.php') didn't return
    >the right value.this always show "file doesn't exists'
    include() uses include_path to search for files.
    file_exists() doesn't.

    >my environment is win2003+iis+php 5
    >
    >how to fix it ?
    The fix may be to correct the "right" value. Don't think that!

    Comment

    • +86

      #3
      Re: problem with 'include' and 'file_exists' function


      "Gordon Burditt дµÀ£º
      "
      thanks for your answer.
      >
      There are plenty of situations where this will happen. If a file
      name begins with ./, it will be looked up with include_path relative
      only to the current working directory, not the current script.
      >
      Are you SURE you know what the current working directory is when
      the script is started?
      The dicrecory is named 'test'.There's no file name like './',All files
      in it ara 'info.php' and 'inc.php', if the current working directory is
      'test' when i browse 'info.php'?
      In this case if the two way to include is different?

      include() uses include_path to search for files.
      file_exists() doesn't.
      I never set include_path before using win2003 and the win2000 server
      run well.
      >
      my environment is win2003+iis+php 5

      how to fix it ?
      >
      The fix may be to correct the "right" value. Don't think that!
      I think you can tell me how to resolve this problem..thanks :)

      Comment

      • Gordon Burditt

        #4
        Re: problem with 'include' and 'file_exists' function

        >There are plenty of situations where this will happen. If a file
        >name begins with ./, it will be looked up with include_path relative
        >only to the current working directory, not the current script.
        >>
        >Are you SURE you know what the current working directory is when
        >the script is started?
        >
        >The dicrecory is named 'test'.There's no file name like './',
        One of the file names you passed to include() began with period slash.
        The comma is punctuation in the sentence.
        >All files
        >in it ara 'info.php' and 'inc.php', if the current working directory is
        >'test' when i browse 'info.php'?
        If file_exists('in c.php') returns false, then the current working
        directory is a directory that does NOT have an inc.php in it. On
        the other hand, the directory the script is in apparently DOES have
        an inc.php in it. include('inc.ph p') searches both places.
        include('./inc.php') only searches the first one. Are you SURE you
        know what the current working directory is when the script is
        started?
        >In this case if the two way to include is different?
        Read the documentation on include(). If the file name begins with
        period slash, fewer directories are searched.

        include('inc.ph p') may search in a lot of places.
        include ('./inc.php') may search in fewer places.
        file_exists('in c.php') looks in ONE place.

        >include() uses include_path to search for files.
        >file_exists( ) doesn't.
        >
        >I never set include_path before using win2003 and the win2000 server
        >run well.
        Are all the path names on win2000 and win2003 *EXACTLY* the same?

        So what is the value of include_path? If you didn't set it, there's
        a default value.
        >my environment is win2003+iis+php 5
        >
        >how to fix it ?
        >>
        >The fix may be to correct the "right" value. Don't think that!
        >
        >I think you can tell me how to resolve this problem..thanks :)
        Print out the current working directory by calling getcwd() and echo
        the value. Is it the value you thought it was?


        Comment

        • alexandr.kosarev@gmail.com

          #5
          Re: problem with 'include' and 'file_exists' function


          +86 wrote:
          i encountered this problem:
          "include('inc.p hp')" will work problely
          but "include('./inc.php') doesn't work ..
          both file_exists('in c.php') or file_exists('./inc.php') didn't return
          the right value.this always show "file doesn't exists'
          >
          my environment is win2003+iis+php 5
          >
          how to fix it ?
          >
          sorry to my English
          >
          thanks to you.
          >
          :)
          Can you post output of this code:
          $d = dir("./");
          echo "Path: " . $d->path . "\n";
          while (false !== ($entry = $d->read())) {
          echo $entry."\n";
          }
          $d->close();

          It will show what you have in "./". Add it before include.

          Comment

          • +86

            #6
            Re: problem with 'include' and 'file_exists' function

            Thanks to you .

            I found this problem is caused by authority .

            the server run well now but don't determined how did I rosolve this
            problem..:(

            Comment

            • Jerry Stuckle

              #7
              Re: problem with 'include' and 'file_exists' function

              +86 wrote:
              Thanks to you .
              >
              I found this problem is caused by authority .
              >
              the server run well now but don't determined how did I rosolve this
              problem..:(
              >
              You'll probably have to change the security info in your server. I
              might suggest a Windows server admin newsgroup - they'll know a lot more
              about how to do it.

              --
              =============== ===
              Remove the "x" from my email address
              Jerry Stuckle
              JDS Computer Training Corp.
              jstucklex@attgl obal.net
              =============== ===

              Comment

              Working...