简体   繁体   English

PHP从cli执行文件,然后从文件运行cli命令?

[英]Php executing file from cli then running a cli command from file?

I know how to run a php built it server from the command line and I know how to execute files from the command line, but what if i want to run a file from php command line interface and run php built-in server from the code inside the file executed by php cli. 我知道如何从命令行运行php内置服务器,也知道如何从命令行执行文件,但是如果我想从php命令行界面运行文件并从代码运行php内置服务器怎么办内部文件由php cli执行。

Is it possible. 可能吗。 If yes, how? 如果是,怎么办?

If no, Then how does the laravel runs the php builtin server by artisan command. 如果否,则laravel如何通过artisan命令运行php内置服务器。

There are multiple ways to executing commandline programs from PHP. 有多种方法可以从PHP执行命令行程序。 There are shell_exec and proc_open. 有shell_exec和proc_open。 shell_exec is the easiest one of them both. shell_exec是两者中最简单的一个。

<?php
  echo shell_exec("whois domain.com"); 
?>

which will output the result from the whois command. 它将从whois命令输出结果。

http://php.net/manual/en/function.shell-exec.php http://php.net/manual/en/function.shell-exec.php

http://php.net/manual/en/function.proc-open.php http://php.net/manual/en/function.proc-open.php

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM