开发者

Can I call python script or function from php

I have the php page which lis开发者_高级运维ts the backups with filename and username. the backups are done with python script but for web interface I used php.

Now I want to put the facility on webpage where there will be button called restore next to backup file name and all the home dir contents are replaced.

I can make the python function with parameters like backup filename , username and it restores the backup.

But I don't know how can I pass variables to python via php


Yes you can call exec("python pythonscript.py someparams"); or if you need to save the output to a variable use this code

exec("python mypythonscript.py someparams",$output);
var_dump($output);

More informaiton: call python script by php and solve errors


You can call the shell from PHP:

  • shell_exec()
  • exec()
  • backticks

and there are more.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜