Reading line by line from STDIN

前端 未结 2 2021
情深已故
情深已故 2020-12-08 18:15

I want to do something like this:

$ [mysql query that produces many lines] | php parse_STDIN.php

In parse_STDIN.php file I wan

2条回答
  •  悲&欢浪女
    2020-12-08 18:55

    use STDIN constant as file handler.

    while($f = fgets(STDIN)){
        echo "line: $f";
    }
    

    Note: fgets on STDIN reads the \n character.

提交回复
热议问题