Editing
Running a Python script from PHP
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
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.net/manual/en/function.exec.php exec()], [http://www.php.net/manual/en/function.system.php system()], [http://www.php.net/manual/en/function.shell-exec.php shell_exec()]<ref>[https://stackoverflow.com/questions/19735250/running-a-python-script-from-php Running a Python script from PHP - Stack Overflow]</ref> ** Pass parameter: Pass the parameter from command line or file ** Possible issues: It the command line is too long, it will reach the [https://docs.microsoft.com/en-US/troubleshoot/windows-client/shell-experience/command-line-string-limitation Command prompt line string limitation]<ref>[https://stackoverflow.com/questions/3205027/maximum-length-of-command-line-string windows - Maximum Length of Command Line String - Stack Overflow]</ref>. & To avoid [https://owasp.org/www-community/attacks/Command_Injection Command Injection] using [https://www.php.net/manual/en/function.escapeshellcmd.php PHP: escapeshellcmd()]. * HTTP GET request ** Method: Using PHP function such as [https://www.php.net/manual/en/function.file-get-contents.php file_get_contents()] or PHP cUrl library [https://www.php.net/manual/en/book.curl.php Client URL Library] ** Pass parameter: GET parameter ** Possible issues: Maximum length of HTTP GET request<ref>[https://helpx.adobe.com/mt/experience-manager/scene7/kb/base/is_protocol-_-forming_is/url-character-limit-get-requests.html URL character limit for Get requests | Scene7]</ref> * HTTP POST request ** Method: Using PHP function such as [https://www.php.net/manual/en/function.file-get-contents.php file_get_contents()]<ref>[https://stackoverflow.com/questions/2445276/how-to-post-data-in-php-using-file-get-contents http - How to post data in PHP using file_get_contents? - Stack Overflow]</ref> or PHP cUrl library [https://www.php.net/manual/en/book.curl.php Client URL Library] ** Pass parameter: POST form data or payload ** Possible issues: == References == <references /> [[Category:Programming]] [[Category:PHP]] [[Category:Python]]
Summary:
Please note that all contributions to LemonWiki共筆 are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
LemonWiki:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Template:Draft
(
edit
)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Current events
Recent changes
Random page
Help
Categories
Tools
What links here
Related changes
Special pages
Page information