Execute command line via php?

半世苍凉 提交于 2019-11-27 18:19:55

问题


How I can execute those two command line via php:

wkhtmltopdf www.google.com gg.pdf

&

oofice -headless -nologo -pt cup-pdf my.doc

they both return a pdf file and download into my home directory.

I want to know the way to execute those command from my html page via php.

Thanks.


回答1:


You should take a look at the System program execution section of the manual : PHP provides several functions that can be used to launch external commands / programs, including :

  • exec() -- which can store the output of the command in an array
  • shell_exec() -- which returns, as a string, the output of the command
  • system() -- which echoes the output of the command



回答2:


To create a pdf from php(in linux) you must use a wrapper.

$cmd = '/usr/bin/xvfb-run --server-args="-screen 0, 1920x1080x24" /usr/bin/wkhtmltopdf http://google.com /tmp/google.pdf';

exec($cmd);


来源:https://stackoverflow.com/questions/6796617/execute-command-line-via-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!