- Basic Functionality
- Executes external programs in PHP
- Returns last line from command output
- Emits E_WARNING if command fails to execute
- Throws ValueError for empty or null command
- Output Handling
- Output array populated with command lines
- Trailing whitespace not included in output
- Array elements automatically appended if present
- Can use unset() to prevent array appending
- Background Execution
- Requires redirecting output to file or stream
- Windows starts cmd.exe first
- Linux uses "> /path/to/file &" for background execution
- Multiple exec commands on same user may freeze server
- Special Considerations
- Escapeshellcmd() recommended for user-supplied data
- Cannot pass Perl arrays directly
- Cannot handle SIGCHLD signals without proper cleanup
- Cannot handle network connections in background executions