使用未定义的常量STDIN - 假设'STDIN'[重复]

<?php
echo "Hello there. So I hear you're learning to be a PHP programmer!
";
echo "Why don't you type in your name for me:
";
$name = trim(fgets(STDIN));
echo "
Thanks, " . $name . ", it's really nice to meet you.

";
?>

a am using php version 5.5.19 xampp

</div>
<?php

echo "Hello there. So I hear you're learning to be a PHP programmer!
";

echo "Why don't you type in your name for me:
";

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

$name=trim(fgets($stdin));

echo "
Thanks, " . $name . ", it's really nice to meet you.

";

fclose($file);

?> 

Assuming you are running from command line interface (CLI):

Define a STDIN constant at the top of your file:

define('STDIN', fopen('php://stdin', 'r'));

Or just replace STDIN constant with:

$name = trim(fgets(fopen('php://stdin', 'r')));