Search
 
SCRIPT & CODE EXAMPLE
 

PHP

python to php

Depending on what you are doing, system() or popen() may be perfect. Use system() if the Python script has no output, or if you want the Python script's output to go directly to the browser. Use popen() if you want to write data to the Python script's standard input, or read data from the Python script's standard output in php. popen() will only let you read or write, but not both. If you want both, check out proc_open(), but with two way communication between programs you need to be careful to avoid deadlocks, where each program is waiting for the other to do something.

If you want to pass user supplied data to the Python script, then the big thing to be careful about is command injection. If you aren't careful, your user could send you data like "; evilcommand ;" and make your program execute arbitrary commands against your will.

escapeshellarg() and escapeshellcmd() can help with this, but personally I like to remove everything that isn't a known good character, using something like

preg_replace('/[^a-zA-Z0-9]/', '', $str)
Comment

PREVIOUS NEXT
Code Example
Php :: laravel migration softdelete 
Php :: prestashop category as homepage 
Php :: show all tags 
Php :: required if null / require without laravel 
Php :: ’ php 
Php :: get woocommerce customers object 
Php :: drupal 7 hook_node_insert 
Php :: create product model in laravel 
Php :: php artisan tinker new record 
Php :: How to generate a create table script for an existing table in php/Codeigniter 
Php :: laravel select option form add please select option 
Php :: kinsta check environment 
Php :: Determine the percentage of the file uploaded to the server using php 
Php :: PHP Installation broken - shows strange php code as response 
Php :: User.php 
Php :: get auth guard user laravel 
Php :: php artisan spark not working in codeigniter 
Php :: termii curl otp 
Php :: comment_info 
Php :: PHP 7 - Fatal error: Call to undefined method PDF::FPDF() 
Php :: php base64 encode utf8 
Php :: wordpress show notice only on plugin page 
Php :: yii1 anchor tag 
Php :: array.diff solution 
Php :: wc php after login redirect page 
Php :: collection methods laravel 
Php :: how to create a modal in php 
Php :: laravel data type 
Php :: random number php 
Php :: wp-admin File not found (404 error) 
ADD CONTENT
Topic
Content
Source link
Name
8+4 =