PHP Classes

File: example_parser.php

Recommend this page to a friend!
  Classes of Er Galvão Abbott   PHP File System Parser   example_parser.php   Download  
File: example_parser.php
Role: Example script
Content type: text/plain
Description: An usage example
Class: PHP File System Parser
Get the list of files, directories
Author: By
Last change:
Date: 16 years ago
Size: 914 bytes
 

Contents

Class file image Download
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */

require 'class.file_system_parser.php';

if (
$_SERVER['argc'] > 1) {
   
$param = $_SERVER['argv'][1];
   
   
   
$parser = new FileSystemParser($param, true);
   
$parser->beginParse();
   
$results = $parser->setResults(true);
   
    echo
'Dirs: ' . $results['dir_count'] . PHP_EOL;
    echo
'Files: ' . $results['file_count'] . PHP_EOL;
    echo
'Links: ' . $results['link_count'] . PHP_EOL;
   
    echo
"-------------------" . PHP_EOL;
    echo
'Dirs: ' . PHP_EOL . join(PHP_EOL, $results['dirs']) . PHP_EOL . PHP_EOL;
    echo
'Files: ' . PHP_EOL . join(PHP_EOL, $results['files']) . PHP_EOL . PHP_EOL;
    echo
'Links: ' . PHP_EOL;
    foreach(
$results['links'] as $link => $target) {
        echo
$link . ' -> ' . $target . PHP_EOL;
    }
   
    echo
PHP_EOL . PHP_EOL;
} else {
    die(
'No directory to parse.');
}
?>