xref: /PHP-7.1/ext/spl/examples/tree.php (revision 95262f8a)
1<?php
2
3/** @file   tree.php
4 * @brief   Program Tree view example
5 * @ingroup Examples
6 * @author  Marcus Boerger
7 * @date    2003 - 2005
8 *
9 * Usage: php tree.php \<path\>
10 *
11 * Simply specify the path to tree with parameter \<path\>.
12 */
13
14// The following line only operates on classes which are converted to c already.
15// But does not generate a graphical output.
16//foreach(new RecursiveIteratorIterator(new ParentIterator(new RecursiveDirectoryIterator($argv[1])), 1) as $file) {
17
18if ($argc < 2) {
19	echo <<<EOF
20Usage: php ${_SERVER['PHP_SELF']} <path>
21
22Displays a graphical tree for the given <path>.
23
24<path> The directory for which to generate the tree graph.
25
26
27EOF;
28	exit(1);
29}
30
31if (!class_exists("DirectoryTreeIterator", false)) require_once("directorytreeiterator.inc");
32if (!class_exists("DirectoryGraphIterator", false)) require_once("directorygraphiterator.inc");
33
34echo $argv[1]."\n";
35foreach(new DirectoryGraphIterator($argv[1]) as $file)
36{
37	echo $file . "\n";
38}
39
40?>
41