redirect a file contents to standard input in php

我们两清 提交于 2020-01-11 10:11:57

问题


I have a file abc.txt with contents like:

hello
hi
good
bad
...
....

Now, How to redirect the contents of the file line by line to a php script's standard input, so that when the php script is executed, it can collect the inputs by any of these commands:

$f = fopen('php://stdin', 'r');
$line = fgets($f);

or

$f = fgets(STDIN);

回答1:


php yourscript.php < yourinputfile

should do the trick.



来源:https://stackoverflow.com/questions/6321198/redirect-a-file-contents-to-standard-input-in-php

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!