Fwrite function in PHP

Source: Internet
Author: User
{Code ...} for example, if I write aa $ msg on the keyboard, the problem is that $ msg is not & quot; input & quot; or & quot; input aa & quot ;, and why does the program stop there for input? Shouldn't php be executed directly?
Fwrite (STDOUT, "input"); $ msg = fgets (STDIN); echo PHP_EOL. $ msg. PHP_EOL;

For example, I write aa on the keyboard.
$ Msg is aa
My problem is why $ msg is not "input" or "input aa ",
And why does the program stop there for input?
Shouldn't php be executed directly?

Reply content:
Fwrite (STDOUT, "input"); $ msg = fgets (STDIN); echo PHP_EOL. $ msg. PHP_EOL;

For example, I write aa on the keyboard.
$ Msg is aa
My problem is why $ msg is not "input" or "input aa ",
And why does the program stop there for input?
Shouldn't php be executed directly?

1. fgets obtains STDIN input, excluding the "input" string;
2. fgets stops reading a linefeed, EOF, or a string of a specified length (1 K by default). Entering a few letters will not stop;
3. PHP is executed sequentially.

File Operation documentation
Http://php.net/manual/zh/ref.filesystem.php

Document of the standard input/output stream
Http://php.net/manual/zh/wrappers.php.php

Command Line Mode development documentation
Http://php.net/manual/zh/features.commandline.php

If you have learned this, please pay for it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.