Python script in php code

At first we create a php file and we name it: test.php.

<?php

$python = exec(`python hello.py`);
echo $python;

?>



As we see, there is a variable called: $python. This variable keeps the output of hello.py file.

hello.py :


print  "If you can read this inside a Web-Browser window, you can successfully run Python through XAMPP!'"




Now is time check if test.php is going to browse python's file message.

We save both files in a sub-directory of htdocs of xampp (let's call this sub-directory 'my_projects')

Now we type at url http://localhost/my_projects/hello.php.

We have to see in our browser the python's file message,as it looks below.


Comments

Popular posts from this blog

Vertex Cover (python implementation)

Transportation Problem (Vogel algorithm python)

IP scanning in python