DIR(3) 1 DIR(3)dir - Return an instance of the Directory classSYNOPSIS
Directory dir (string $directory, [resource $context])
DESCRIPTION
A pseudo-object oriented mechanism for reading a directory. The given $directory is opened.
PARAMETERS
o $directory
- Directory to open
o $context
-
Note
Context support was added with PHP 5.0.0. For a description of contexts, refer to "Streams".
RETURN VALUES
Returns an instance of Directory, or NULL with wrong parameters, or FALSE in case of another error.
EXAMPLES
Example #1
dir(3) example
Please note the fashion in which Directory.read(3)'s return value is checked in the example below. We are explicitly testing
whether the return value is identical to (equal to and of the same type as - see Comparison Operators for more information) FALSE
since otherwise, any directory entry whose name evaluates to FALSE will stop the loop.
<?php
$d = dir("/etc/php5");
echo "Handle: " . $d->handle . "
";
echo "Path: " . $d->path . "
";
while (false !== ($entry = $d->read())) {
echo $entry."
";
}
$d->close();
?>
The above example will output something similar to:
Handle: Resource id #2
Path: /etc/php5
apache
cgi
cli
NOTES
Note
The order in which directory entries are returned by the read method is system-dependent.
PHP Documentation Group DIR(3)
Check Out this Related Man Page
METHOD_EXISTS(3) 1 METHOD_EXISTS(3)method_exists - Checks if the class method existsSYNOPSIS
bool method_exists (mixed $object, string $method_name)
DESCRIPTION
Checks if the class method exists in the given $object.
PARAMETERS
o $object
- An object instance or a class name
o $method_name
- The method name
RETURN VALUES
Returns TRUE if the method given by $method_name has been defined for the given $object, FALSE otherwise.
NOTES
Note
Using this function will use any registered autoloaders if the class is not already known.
EXAMPLES
Example #1
method_exists(3) example
<?php
$directory = new Directory('.');
var_dump(method_exists($directory,'read'));
?>
The above example will output:
bool(true)
Example #2
Static method_exists(3) example
<?php
var_dump(method_exists('Directory','read'));
?>
The above example will output:
bool(true)
SEE ALSO function_exists(3), is_callable(3), class_exists(3).
PHP Documentation Group METHOD_EXISTS(3)
Say, I want to move into dir library from current dir, on prompt if I type in
cd li
if it is followed by pressing 'Tab' key then complete dir name appears.
Would there anyone know, how we can make into effect this path autocompletion?
I am using 'ksh'. (5 Replies)
Hi,
I have written this shell script:
fl=`ls -1lrt $mylist | grep '\.xml$' | awk '{print $9}'`
echo $fl (1)
for i in $fl
do
for dir in $mylist
do
if
then
echo $dir/$i >> tmp (2)
fi
done
done
The mylist contains some directory names. The satement (1) gives the sorted list... (5 Replies)
Hi Experts,
Is there any way to link the contents (subdirectories/files) of a existing directory A to another existent directory B..
The relative path of /root/Directory A/
Directory A
|__ Subdirectory A1
|__File A
|__File B
|__ Subdirectory A2
|__File A
... (6 Replies)
Hi All,
As I m very new for Unix, I need to check for a directory and move a file. If Directory is not found, The script should create a directory and move the file. Can any one help here. (7 Replies)
$ export ABC1=/my/dir
$ export t=2
$ echo $ABC1
/my/dir
$ echo $ABC$t
2
$ echo $ABC${t}
2
I tried different ways but couldnet get expected result...
can some one let me know where am wrong and what would i need to type to get correct output by giving variable t (7 Replies)
Hi,
I am using the below query to find files from a Directory:
SOURCE_DIR--Directory
Files in the Directory:
ABC.log
XYZ.out
The SOURCE_DIR has subdirectory....
when i use the below command...
find /apps/informatica/node1/scripts/test '(' -name '*.log' -o -name '*.out'... (12 Replies)
Hi All,
I am currently coding for a requirement(LINUX OS) where I am supposed to move a file (Lets Call it Employee.txt) from Directory A to Directory B based on 2 date fields as below,
Date_Current = 20120620
Date_Previous = 20120610
Source Directory : /iis_data/source
Target... (11 Replies)
Hi
I want to use echo command as below
echo 'dir=' $1 ' dir|file|home'
i need output like below :
echo 'dir=' $1 ' dir|file|home' pp13dff
Output
dir=pp13dff dir|file|home (4 Replies)
Hello All,
I installed php5 from OpenCSW but i believe it does not support the expect module.
I tried to run a php script to call expect to do a telnet to a device but i got this error
PHP Warning: fopen(): Unable to find the wrapper "expect" - did you forget to enable it when you... (6 Replies)
Greetings to you. I have a quick question for the community today ;)
I'm interested in the following format for recursive output from a command such as "ls" or "dir" when pointed to a folder:
...but there doesn't seem to be coverage for this type of output formatting in the manpages.
Maybe... (11 Replies)
This script writes the output files to FILES but I don't want to exclude all directories from ABC_CHQ and LYS_ADV, I want to include one sub directory name process which is under ABC_CHQ and LYS_ADV in the search. Right now its excluding everything from prune directories such as ABC_CHQ, LYS_ADV... (10 Replies)