Tag Archives: Directory

configure: error: BDB/HDB: BerkeleyDB not available

Looks like BerkeleyDB is not installed which is required to configured openLDAP.

Follow the below steps to install BerkeleyDB.

Downloading Berkeley DB

wget http://download.oracle.com/berkeley-db/db-5.2.28.tar.gz

Extracting files from the downloaded package:

tar zxvf db-5.2.28.tar.gz

cd db-5.2.28/build_unix

Create installation path

mkdir /etc/berkeleydb

Configuring Berkeley DB

../dist/configure --prefix=/etc/berkeleydb

Compile and install the code

make

make install
Share

scandir

it lists files and directories of a given path.

Example

<?php
echo “<pre>”;
$dir    = ‘/var/www/test/’;
$files1 = scandir($dir);
print_r($files1);
?>

Output

Array
(
[0] => .
[1] => ..
[2] => index.php
[3] => enc.php
)

Share

rewinddir

It rewinds directory handle and can be used to check for changes in a directory.

Example

<?php
$dir = opendir(“/var/www/test/”);
while (($file = readdir($dir)) !== false)
echo  $file . “<br />”;
rewinddir($dir);
closedir($dir);
?>

Output

index.php
..
.

Share

dir

It return an instance of the Directory class

Example

<?php
$dir = dir(“/var/www/test/date/”);
echo “Handle: ” . $dir->handle . “<br />”;
echo “Path: ” . $dir->path . “<br />”;
while (($val = $dir->read())  !== false) {
echo $val.”<br />”;
}
$dir->close();
?>

Output

Handle: Resource id #3
Path: /var/www/test/date/
index.php
enc.php
..
.

Share

closedir

It closes directory handle

Example

<?php
$path = “/var/www/test/”;
if (is_dir($path)) {
if ($dir = opendir($path)) {
echo $directory = readdir($dir);
closedir($dir);
}
}
?>

Output

index.php

Share