1

Im working on a PHP script that is executing chosen website projects. (Only on my local computer).

What i would want it to do is execute ALL files it can find in a folder. It would take time to always change the code when i add a, for example, .php file or .css file.

Im using windows 7.

Is it possible somehow?

Code so far:

exec("C:\\xampp\\htdocs\\project\\",$output, $return);
1
  • 2
    Use glob() and exec each one. php.net/glob Commented Apr 30, 2013 at 14:08

1 Answer 1

2
foreach (glob("path/ToFile/*.php") as $filename) {
    exec($filename, $output); // previously $Filename
}

Perhaps this might perform the task you require

foreach (glob("path/ToFile/*.php") as $filename) {
 echo $filename."<br>";
}

See if you are getting any files

Sign up to request clarification or add additional context in comments.

4 Comments

No idea why, but it didnt work. Tried both path from script and from windows harddrive.
@user2336174 See my update, echo out the filename to see if it's correctly populated
It is, got all the names. This is the error: Warning: exec(): Cannot execute a blank command in, Notice: Undefined variable: Filename i
I see it too now, haha! Thanks for the help! Appreciate it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.