Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6909507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:41:54+00:00 2026-05-27T08:41:54+00:00

hoping you can help me out with this question! Index.php include_once ‘files.class.php’; $file_object =

  • 0

hoping you can help me out with this question!

Index.php

include_once 'files.class.php';
$file_object = new FileObject('resources');
$file_object->ReturnCurrentDirectoryList();

files.class.php

class FileObject{
public $directory_list;

    function __construct($current_directory_in){
        $this->directory_list = $this->BuildCurrentDirectoryList($current_directory_in);
    }

    function BuildCurrentDirectoryList($current_directory_in){
        $i = 0;
        $iterator = new DirectoryIterator($current_directory_in);

        foreach ($iterator as $fileinfo){
            if ($fileinfo->isDir()){
                $this->directory_list[$i]['pathname'] = $fileinfo->getPathname();
            }elseif($fileinfo->isFile()){
                $this->directory_list[$i]['filename'] = $fileinfo->getFilename();
            }
            $i++;
        }
    }

    function ReturnCurrentDirectoryList(){
        var_dump($this->directory_list);
    }
}

At the end of all this, what is returned is

null

but what should be returned is

array  0 =>  array 'pathname' => string 'resources\.',  1 => array 'pathname' => string 'resources\..', 2 =>  array 'pathname' => string 'resources\Images'

I’m somewhat new to classes/methods..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T08:41:55+00:00Added an answer on May 27, 2026 at 8:41 am

    This is wrong:

    $this->directory_list = $this->BuildCurrentDirectoryList($current_directory_in);
    

    You assign to $this->directory_list but BuildCurrentDirectoryList does not return anything. The function have side-effects only, no return value.

    Remove the assignment so the constructor looks like this and you should be good to go:

    $this->directory_list = array(); //I like to initialise arrays to the empty array
    $this->BuildCurrentDirectoryList($current_directory_in);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am hoping that somebody can help me out with this question. The following
I am hoping someone can help me out with a quick question I have
As a follow-up to this question I am hoping someone can help with the
hoping someone can help me out with this. I'm trying to figure out whether
I`m hoping can help me out with a file creation/response question. I know how
I am new to iPhone programming so am hoping someone can help me out
I'm hoping someone can help out with this. I modified code from jQuery and
Alright, I am hoping someone can help me out. I apologize up front that
I am out of ideas here, so I'm hoping someone can help. Here is
im hoping someone can help me quickly with a question i have. As site

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.