Should external programs called by exec() in PHP be PHP files or files on the server?
When using the exec() function in PHP to call external programs, the programs being called can be PHP files or any other type of executable file on the server. It ultimately depends on what the external program is meant to do and how it is designed. If the external program needs to interact with PHP data or functions, it may be beneficial to have it as a PHP file. Otherwise, any executable file can be called using exec().
// Example of calling an external program that is a PHP file
exec('php /path/to/external_program.php');
// Example of calling an external program that is not a PHP file
exec('/path/to/external_program');
Keywords
Related Questions
- What are common issues when using move_upload_file function in PHP under Windows IIS?
- What are the best practices for handling character encoding in PHP headers for file output?
- How can methods be used in PHP classes to handle error messages and avoid including output generation within the class itself?