473,513 Members | 2,605 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:

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
1 2397
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
4937
by: bart | last post by:
i run 4.3.4 but is_dir doesn't work always. when i put a counter in a readdir loop, it returns the number 5 that is; .. ...
4
3807
by: lawrence | last post by:
In the function below, before I open the directory I first test to make sure the address I have is, in fact, a directory. This function was working fine on one web server running FreeBSD and PHP...
5
2709
by: ravenslay3r | last post by:
I'm using a script to grab images from a directory and put them to the screen, but i want it to ignore sub-directories like CVS/ . Adding the tag "&& !is_dir($file)" to the correct conditional...
7
3279
by: George Hester | last post by:
Please take a look at this google artcle: http://groups.google.com/groups?hl=en&lr=&frame=right&th=55d6f4b50f5f9382&seekm=411f370d%241%40olaf.komtel.net#link9 The op was having trouble with...
2
2454
by: Anthony Cuttitta Jr. | last post by:
We have an application that outputs several different graphs from data downloaded from our AS400. The application has worked without (this) issue for several months now, but just recently, the...
2
2803
by: Ben Rush | last post by:
Hello World, Okay, I have spent the day browsing the newsgroups and reading up on article after article concerning ViewState corruption and so forth, and I have a couple questions. We...
2
2574
by: Juby | last post by:
I'm creating a script for our website which will function as something of a docment manager. The backend features an option to create a new directory in the uploads subdirectory. The problem is,...
12
2313
by: comp.lang.php | last post by:
Env: Windows XP, Apache 1.33, PHP 5.2.0 <? echo is_dir($_SERVER) . " for dir = " . $_SERVER); ?>
13
3477
by: SAL | last post by:
Hello, I'm trying to include a popup in the ItemTemplate of a gridview row. The ItemTemplate for the field contains a textbox and when the user clicks in the textbox I want a popup panel to show...
0
7260
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7537
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7099
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5685
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4746
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3233
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3222
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1594
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
456
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.