stdin in php is a constant, its function is to read content from the console. When encountering this constant or opening the "php://stdin" script through the fopen() function, it will wait for user input. , until the user presses the Enter key to submit.
#The operating environment of this article: Windows 7 system, PHP version 7.4, Dell G3 computer.
What does stdin mean?
PHP STDIN usage:
"STDIN" in PHP language is used for slave control The platform reads content. When encountering this constant or opening php://stdin through the fopen() function, the script will wait for the user to input content until the user presses the Enter key to submit.
Write a stdin.php and test it:
<?php echo "请输入内容:"; $jimmy = fgets(STDIN); echo sprintf("输入的内容为: %s\n", $jimmy); $demo = fopen('php://stdin', 'r'); echo "请输入: "; $test = fread($demo, 12); //最多读取12个字符 echo sprintf("输入为: %s\n", $test); fclose($demo);
Running results:
请输入内容:sad 输入的内容为: sad 请输入: asdasdasdasdasdasd 输入为: asdasdasdasd(这里因为设置了最多读取12个字符,设置更多一些就可以完整显示)
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of What does php stdin mean?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SublimeText3 English version
Recommended: Win version, supports code prompts!

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SublimeText3 Linux new version
SublimeText3 Linux latest version

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.
