chdir

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bahbah
    Senior Member
    • Dec 2001
    • 606
    • 3.8.x

    chdir

    Hi,

    I was hoping someone could help me to understand chdir properly.

    I need to use chdir to require a script.

    By chdir'ing I am able to require the script properly.

    By chdir'ing one of the other scripts on the same page breaks.

    For example:

    If I have a php script includes others. Where is that script executed ?

    If I have a php script with a require that uses chdir. Where is that script executed ?

    If I have a php script with 2 requires that uses a chdir for one of them where is the script initially executed ? and would chdiring back to this location allow the other script to run ?

    Confused ? Me too!

    Thanks
  • Steve Machol
    Former Customer Support Manager
    • Jul 2000
    • 154488

    #2
    Are you running on a Windows server by any chance? I've seen some Windows servers have problems with the chdir function.
    Steve Machol, former vBulletin Customer Support Manager (and NOT retired!)
    Change CKEditor Colors to Match Style (for 4.1.4 and above)

    Steve Machol Photography


    Mankind is the only creature smart enough to know its own history, and dumb enough to ignore it.


    Comment

    • bahbah
      Senior Member
      • Dec 2001
      • 606
      • 3.8.x

      #3
      Linux thanks Steve

      Comment

      • Razz
        Member
        • Jun 2001
        • 54

        #4
        I'm not 100% sure on this as I have never needed to use it yet in a script, but I'm sure that if you're using relative paths in your includes, once you use chdir you need to allow for the directory change in your relative paths.

        Comment

        • Ken Iovino
          Senior Member
          • Jan 2003
          • 463
          • 3.7.x

          #5
          chdir(); Is pretty simple to understand.

          I use this on my site for my custom portal page. In my /root/index.php file i have this:
          PHP Code:
          chdir('/home/vbhacker/public_html/forum/');
          require_once(
          './global.php');
          require_once(
          './includes/functions_bbcodeparse.php'); 
          What that does is places my index.php file in the /root/forum/ enviorment. It doesn't acually move it there, but it munipulates the code to belive its there.
          Ken Iovino
          Full Time PHP, Ruby and iOS Developer

          Comment

          widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
          Working...