Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    May 2010
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Arrow how to explore a directory with the php

    hello,
    today we will know how to know the content of any folder with the php with a simple code
    first you should download this simple class

    then we can use it for that
    just include it
    PHP Code:
    require_once ('readDir.class.php'); 
    and start new one
    then you have to set the path of your folder
    PHP Code:
    if (!$dir->setPath$base_dir.'/example' )) {
        die(
    $dir->error());

    know if you want to make the system going on any sub folder just use
    PHP Code:
    $dir->readRecursive(true); 
    and you can use the call back system in the class just like that
    PHP Code:
    // set a function to call when a new dir is read
    if (!$dir->setEvent'readDir_dir''my_dir_function' )) { ;
        die(
    $dir->error());

    // set a function to call when a new file is read
    if (!$dir->setEvent'readDir_file''my_file_function' )) {
        die(
    $dir->error());

    you can see the example:example.php
    and you can make the system stoping at a specifice point just like that
    PHP Code:
        if ($filename == 'secret_php_file.php') {
            echo 
    'We found the file we are looking for. Stopping directory read.<br />';

            return -
    1// return negative 1 to stop the reading of the directory
        


  • #2
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,108
    Thanks
    11
    Thanked 101 Times in 99 Posts
    as of PHP5 PHP has built-in classes for this , see http://au.php.net/recursivedirectoryiterator
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #3
    New to the CF scene
    Join Date
    May 2010
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    oh great this the first time i konw that
    thank u


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •