Run a PHP CLI script from a webpage

后端 未结 2 1604
难免孤独
难免孤独 2021-01-19 15:08

I have a (possibly dumb) question. I have a script made in php, constructed for cli usage. Works fine when I run it from the command line, no problem there. The problem is t

2条回答
  •  轮回少年
    2021-01-19 15:24

    maybe update the php script to be both an include and a cli script.

    use

    __FILE__ 
    

    to check if it's a file, then read the params. otherwise do nothing.

    and as an include just call the function you want directly.

提交回复
热议问题