Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9040097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:53:58+00:00 2026-06-16T09:53:58+00:00

Is it possible to run a Python script within PHP and transferring variables from

  • 0

Is it possible to run a Python script within PHP and transferring variables from each other ?

I have a class that scraps websites for data in a certain global way. i want to make it go a lot more specific and already have pythons scripts specific to several website.

I am looking for a way to incorporate those inside my class.

Is safe and reliable data transfer between the two even possible ? if so how difficult it is to get something like that going ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T09:54:00+00:00Added an answer on June 16, 2026 at 9:54 am

    You can generally communicate between languages by using common language formats, and using stdin and stdout to communicate the data.

    Example with PHP/Python using a shell argument to send the initial data via JSON

    PHP:

    // This is the data you want to pass to Python
    $data = array('as', 'df', 'gh');
    
    // Execute the python script with the JSON data
    $result = shell_exec('python /path/to/myScript.py ' . escapeshellarg(json_encode($data)));
    
    // Decode the result
    $resultData = json_decode($result, true);
    
    // This will contain: array('status' => 'Yes!')
    var_dump($resultData);
    

    Python:

    import sys, json
    
    # Load the data that PHP sent us
    try:
        data = json.loads(sys.argv[1])
    except:
        print "ERROR"
        sys.exit(1)
    
    # Generate some data to send to PHP
    result = {'status': 'Yes!'}
    
    # Send it to stdout (to PHP)
    print json.dumps(result)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Run python script without DOS shell appearing I have a python script
Possible Duplicate: Request UAC elevation from within a Python script? I'd like to execute
I have a action.php script from where I call a python script like this:
Is it possible to run a PHP script using python?
Possible Duplicate: How to send an e-mail from a Python script that is being
Is it possible to call/run a python script file from Java code on the
Is it possible to run hip-hop php in cygwin which is using more script
Lets say i have a python script at homedir/codes/py/run.py I also have a bash
I have a python script that invokes the following command: # make After make,
Is it possible to run a Python script as a background service on a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.