PHP Classes
elePHPant
Icontem

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Ciprian Voicu  >  Pictoru's File Tree  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example file
Class: Pictoru's File Tree
Retrieve list of files and folders recursively
Author: By
Last change: examples
Date: 8 years ago
Size: 1,957 bytes
 

Contents

Class file image Download
<?php
/*
 +--------------------------------------------------------------------------+
 | Author : Ciprian Voicu |
 | Email : pictoru at autoportret dot ro |
 +--------------------------------------------------------------------------+
 | Name : Pictoru's File Tree |
 | Filename : example.inc.php |
 | File Type : Base class |
 | Description : Retrieve the list of files and folders and their info |
 | from a specified location and return it as array |
 | of arrays or as array of objects |
 | Created Date : 2007-02-22 |
 | Last Modified : 2007-03-28 |
 +--------------------------------------------------------------------------+
 | License : Free to use for anyone |
 +--------------------------------------------------------------------------+
*/

function showMe($p_var , $p_bReturn=false){
   
$style = 'style="background:#E6FFE6; color:#0000A0; border:1px blue dotted; padding:10 10; text-align:left;" ';
   
$pre = "<div><pre ".$style.">\n%s\n</pre></div>\n";

    if(
is_scalar($p_var)){
        
$strResult = $p_var;
    }else{
       
$strResult = @print_r($p_var,true);

        if(empty(
$strResult)){
           
// test if second paramates is working
           
$retTest= @print_r( array("10") , true);

            if(empty(
$retTest)){
              
// not working capture the output
               
ob_start();
                   @
print_r($p_var);
                  
$strResult=ob_get_contents();
                  
ob_end_clean();
            }
        }
    }

    if(
$p_bReturn===false){
        print
sprintf($pre,$strResult);
    }else{
        return
$strResult;
    }
}
#
require_once "PFileTree.inc.php";
#
$root=realpath(dirname(__FILE__));
$sub='classes/PFileTree';
#
$f=new PFileTree();
#
$list=$f->ListFiles(".", true, true, 'size type');

//$f->Delete("dir");
showMe($list);
?>