Running a Python script from PHP
Jump to navigation
Jump to search
Running a Python script from PHP
這篇文章「Running a Python script from PHP」內容還在撰寫中,如果有不完整的部分,歡迎你直接動手修改。 |
Different approaches[edit]
- Execute the Python script from command line
- Method: Using PHP function such as exec(), system(), shell_exec()[1]
- Pass parameter: Pass 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 request
- 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 request
- 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: