By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,830 Members | 2,271 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,830 IT Pros & Developers. It's quick & easy.

is_dir() issue.

P: n/a
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:

http://ionline.dk/test/test1.php
http://ionline.dk/test/files/test2.php

Contents of the scripts:

http://ionline.dk/test/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($entry) .
'</td></tr>' . "\n";
}
$dir->close();
echo '</table>'
?>
</body>
</html>
http://ionline.dk/test/test1.php:

<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.
Oct 1 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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
Oct 1 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.