Reputation: 1049
inside ajax folder, there are files: json.php, load.php, script.php
main.php
<?php
$dir = dir("ajax");
while (($file = $dir->read()) !== false)
{
echo "filename: " . $file . "<br />";
}
$dir->close();
It show:
filename: .
filename: ..
filename: json.php
filename: load.php
filename: script.php
Question:
In the result, what does the first two items mean? .
..
?
Upvotes: 1
Views: 53
Reputation: 20155
Single dot: .
This represents current directory.
Double dot: ..
This represents parent directory.
Upvotes: 0
Reputation: 641
.
is current folder.
..
is parent folder. Any folders on window and linux have two this.
If you want to read some type of file, you can use glob
function of php.
$files = glob($dirpath.'/*.php');
Upvotes: 0
Reputation: 5028
Those are the current (.)
and parent (..)
directories.
You can get rid of them in following way:
$result = array_diff($result, array('..', '.'));
Upvotes: 2
Reputation: 6051
.
and ..
are "directories" which equate to the current directory, and parent directory, respectively.
for example, if you are in the ajax folder, json.php
can also be accessed with ./json.php
.
on the other hand, ../json.php
will look for the file in the parent folder (same directory as the ajax
folder).
Upvotes: 0