tags:

views:

35

answers:

1

Hi, I am developing using a Windows 7 machine with the local server being UniServer.

I have some PHP code to include all php files in a directory.

# Include all library classes.
$library_files = scandir(LIBRARY_PATH);
foreach ($library_files as $file) {
    $path_parts = pathinfo($file);
    if ($path_parts['extension'] == 'php') {
        require(LIBRARY_PATH . DIRECTORY_SEPARATOR . $file);
    }
}

Calling the scandir function causes the script to never end. I am not sure if this is a problem with the permissions of the folder. I am able to include files from within the folder.

What is going wrong here? Thankyou.

Edit: LIBRARY_PATH equals E:\Tools\UniServer\www\LIBRARY

Edit: Apparently it is working now. I'm confused, I haven't changed anything at all. I think I might need to reinstall PHP. Thanks for helping

A: 

Calling the scandir function causes the script to never end

A bit vague.

Have you tried running the script from the CLI, writing to stdout after scandir and flushing the output buffer before entering the loop?

What happens if you try to DIR E:\Tools\UniServer\www\LIBRARY at the command prompt?

What happens when you try DIR E:\Tools\UniServer\www\LIBRARY within a PHP script?

symcbean
What I mean is that when I run the script from my browser, it just stops on 'Waiting for localhost...'When I do the first command from the command prompt it returns what is expected.I don't know how to execute the second command from PHP.
NeedsToKnow
Enclose it in backticks or call using shell_exec()
symcbean