does echo equal fputs( STDout )?

后端 未结 1 600
轮回少年
轮回少年 2020-12-24 02:03

Does echo equal fputs( STDOUT ), or does echo write to a different stream? I\'ve used PHP for a while now, but I don\'t know very well

1条回答
  •  粉色の甜心
    2020-12-24 02:33

    According to PHP's manual page on wrappers, the answer is No.

    php://output

    php://output is a write-only stream that allows you to write to the output buffer mechanism in the same way as print() and echo().

    print and echo write to php://output stream, whereas fputs(STDOUT) writes to php://stdout.

    I did a little test:

    This script outputs (tested on PHP 5.2.13, windows):

    writing to stdout directly
    ob_contents: regular echo
    writing to php://output directly
    

    i.e. writing to STDOUT directly bypasses ob handlers.

    0 讨论(0)
提交回复
热议问题