I want to implement one logic which is written in python, this code will do some searching stuffs, and I have a website done in PHP. can any one tell me whether I can include python script in PHP? if yes , how can I do that ?
Criteria : Input to the python script will come from php or html [either text or file]. and output of python is directly displayed to the page or through php or store it in mysql and show it through PHP.[Please suggest me the best one in this].
-
out of curiosity, why cant you do the "searching stuff" with php?Nick– Nick2013年04月15日 13:39:19 +00:00Commented Apr 15, 2013 at 13:39
-
requirement , the code is already written in python and i heard that its alot faster then PHP.Razer– Razer2013年04月15日 13:43:22 +00:00Commented Apr 15, 2013 at 13:43
-
"alot faster than PHP" on its own, in very specific situations, yes. However, PHP is already running in your situation - might as well use it?Sébastien Renauld– Sébastien Renauld2013年04月15日 13:50:10 +00:00Commented Apr 15, 2013 at 13:50
-
see whats happening in python code is : entered Input may be some text or a word file is searched in google. and the result will be multiple site url and content which has matched with the user contents. i really dono how we can do this in php and i dont think it will be faster in php.Razer– Razer2013年04月15日 14:01:07 +00:00Commented Apr 15, 2013 at 14:01
1 Answer 1
If you have access to exec, you can run the python interpreter. However, that's:
- Overkill
- Not necessarily wise
- A major waste of resources
If your logic is simple, why don't you write it in PHP? Furthermore, if your logic is not simple...why don't you make an API of some sort to access it and favour communication rather than code deduplication?