dsa456369 2017-12-19 20:22
浏览 227
已采纳

php中readline与fread / fgets的区别

I have always used readline in my console commands before, but today I've come across the fread and fgets functions and my question is: what is the difference in using these two approaches:

// first
$inputLine = readline();

// second
$inputLine = fgets(STDIN);

they both do pretty much the same, do they not?

  • 写回答

1条回答 默认 最新

  • dongliang1893 2017-12-20 12:54
    关注

    The only possible difference I can think of is just that readline() takes no arguments and can only read input from STDIN by default, whilst fgets() can take any resource to read from. So, in other words readline() is a synonym to fgets with the first predefined argument, like, for instance, fprintf() and printf().

    Consider the following:

    fprintf(STDOUT, "hello!");
    printf("hello!);
    

    This is quite common in php standard library.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换