Running a Python script from PHP: Difference between revisions
Jump to navigation
Jump to search
(Created page with "Running a Python script from PHP {{Draft}} == Different approaches == * Execute the Python script from command line ** Method: Using PHP function such as [https://www.php....") |
(No difference)
|
Revision as of 21:54, 20 June 2021
Running a Python script from PHP
Different approaches
- Execute the Python script from command line
- Method: Using PHP function such as exec(), system(), shell_exec()[1]
- Pass parameter: Ppass the parameter from command line or file
- Possible issues: It the command line is too long, it will reach the Command prompt line string limitation[2]. & To avoid Command Injection using PHP: escapeshellcmd().
- HTTP GET protocol
- Method: Using PHP function such as file_get_contents() or PHP cUrl library Client URL Library
- Pass parameter: GET parameter
- Possible issues: Maximum length of HTTP GET request[3]
- HTTP POST protocol
- Method: Using PHP function such as file_get_contents()[4] or PHP cUrl library Client URL Library
- Pass parameter: POST form data or payload
- Possible issues: