EDIT: I just answered part of my question. exec('ls') only listed a single file but I tried shell_exec('ls') and it listed all the files in the directory. exec only outputs the last file in the list, while shell_exec outputs the whole list as a string.
The only language that I'm really good at is PHP so I use it for everything (i.e. to do stuff on my computer, not just web apps). I run it on an apache server and one problem I have is it can't do anything outside of the /var/www/ (I'm on linux, in Windows its C:/apache/htdocs or something like that) directory. I know that with the exec() function, I can run linux commands and these bash commands aren't confined to /var/www/. I can't do very much at all with this yet though. For example if I run:
echo "<pre>". exec('/home/user/Desktop') . "</pre>";
I would expect it to list all the files on my Desktop, but for some reason it only prints a single file. Weirdly enough, its not even the first alphabetically ordered file, its a random directory. I tried this in the past actually and it worked, I don't know why its not working anymore.
I'm aware that exec isn't the only PHP function that can be used to execute bash commands, are there better ones for this? I came across a way to make exec('ls') load all the files listed by ls into a PHP variables which was very cool. Thats why I started this thread, I want to learn about getting PHP to work together with bash. I'm aware that I can run shell scripts with the exec() function but I haven't experimented with this much yet.