0

I'm trying to pass a variable into shell_exec, I've looked at other tutorials but they still dont help.

I want to pass $var[1] into the shell_exec so it will just display this specific file or directory's information

$output = shell_exec('ls -l'.$var[1]);
1
  • 1
    What is inside $var[1]? Can you do print_r($var[1]) and include the output in your question? Commented Feb 2, 2015 at 14:51

1 Answer 1

1

You should add some whitespace:

$output = shell_exec('ls -l '.$var[1]);
                        // ^here
Sign up to request clarification or add additional context in comments.

7 Comments

LOL, can't believe i missed that..haha thank you though!
You're welcome, please mark the answer as correct if it has helped you
Why does it not display information about a directory? For example if type the name of a folder it doesn't work - will mark as correct once it allows me(10min timer)
I'm not really sure why it doesn't work without seeing what your variable looks like. But if you echo $output, it should work or at least throw an error
$var[1] just gets a file or directory name so like test.php etc
|

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.