is_dir() issue.

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

    is_dir() issue.

    Hello.

    I have a minor issue with is_dir(). When running two almost identical
    scripts from two different directories with same target directory I get
    different output. The only difference between the scripts is a variable
    containing the path to the target directory.

    The scripts are located here:




    Contents of the scripts:



    <html>
    <head>
    <title></title>
    </head>
    <body>
    <?php
    $dir = getcwd() . '/files' ;
    echo '<h1>Listing content of ' . $dir . '</h1>' . "\n";
    echo '<table><tr><td >file</td><td>is_dir() </td></tr>' . "\n";
    $dir = dir($dir);
    while(false !== ($entry = $dir->read())){
    if($entry != 'index.php')
    echo '<tr><td>' . $entry . '</td><td>' . is_dir($entry) .
    '</td></tr>' . "\n";
    }
    $dir->close();
    echo '</table>'
    ?>
    </body>
    </html>




    <html>
    <head>
    <title></title>
    </head>
    <body>
    <?php
    $dir = getcwd();
    echo '<h1>Listing content of ' . $dir . '</h1>' . "\n";
    echo '<table><tr><td >file</td><td>is_dir() </td></tr>' . "\n";
    $dir = dir($dir);
    while(false !== ($entry = $dir->read())){
    if($entry != 'index.php')
    echo '<tr><td>' . $entry . '</td><td>' . is_dir($entry) .
    '</td></tr>' . "\n";
    }
    $dir->close();
    echo '</table>'
    ?>
    </body>
    </html>

    Any suggestions on what is causing this is appreciated.

    Regards.
  • ndlarsen

    #2
    Re: is_dir() issue. [Solved]

    Nevermind this one. Apparently I was looking for the files in the wrong
    directory. Guess it's caused by lack of fresh air. Here's the proper
    content of test1.php :

    <html>
    <head>
    <title></title>
    </head>
    <body>
    <?php
    $dir = getcwd() . '/files' ;
    echo '<h1>Listing content of ' . $dir . '</h1>' . "\n";
    echo '<table><tr><td >file</td><td>is_dir() </td></tr>' . "\n";
    $dir = dir($dir);
    while(false !== ($entry = $dir->read())){
    if($entry != 'index.php')
    echo '<tr><td>' . $entry . '</td><td>' .
    is_dir('files/'.$entry) . '</td></tr>' . "\n";
    }
    $dir->close();
    echo '</table>'
    ?>
    </body>
    </html>


    Regards

    Comment

    Working...