How do I write a command-line interactive PHP script?

后端 未结 9 1931
南旧
南旧 2020-12-23 21:59

I want to write a PHP script that I can use from the command line. I want it to prompt and accept input for a few items, and then spit out some results. I want to do this in

9条回答
  •  清歌不尽
    2020-12-23 22:54

    I found an example on PHP.net, Utiliser PHP en ligne de commande:

    $handle = fopen("php://stdin", "r");
    $line = fgets($handle);
    if (trim($line) != 'yes') {
    ...
    

提交回复
热议问题