nodejs、php命令行交互模式
更新:HHH   时间:2023-1-7


一、NODE JS:

  1. 代码:
    test.js
    var readline = require('readline');
    var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
    });
    rl.question("what is your name?", function(result) {
    console.log(result)
    rl.close();
    });
  2. 测试:

    二、PHP:

  3. 代码:
    test.php
    <?php
    <?php
    while ($result = trim(fgets(STDIN))){
    echo "hello:".$result.PHP_EOL;
    }
  4. 测试:
返回web开发教程...