What is the difference between shell_exec() and exec() in PHP for executing commands?
Hi everyone! I'm new to PHP and trying to execute system commands from a script. I found two functions: shell_exec() and exec(), but I don't understand the difference between them and which one to use when.\n\nI have a simple script that should output a list of files in a directory:\n\n```php\n\n```\n\nThis works, and I see the file list. But when I try exec():\n\n```php\n\n```\n\nIt also seems to work, but the result comes as an array, not a string.\n\nI need to execute different commands: sometimes just check if the command executed successfully (e.g., create a folder), sometimes get the output for further processing (e.g., a list of
No answers yet.
Log in to leave an answer
Blogs