Use of undefined constant STDIN - assumed 'STDIN' in C:\wamp\www\study\sayHello.php on line 5

user3206343 picture user3206343 · Jan 17, 2014 · Viewed 22.7k times · Source

I want to Learn php & mySQL and I purchased a book (php&mySql: the missing manuals 2edition)

I installed Wampserver2.4 on win8 64bit machine.

Server Configuration

Apache Version : 2.4.4
PHP Version : 5.4.12

in first lesson i got this error :(

Notice: Use of undefined constant STDIN - assumed 'STDIN' in C:\wamp\www\study\sayHello.php on line 5

this is the php code on file "sayHello.php"

<?php

echo "Hello there. So I hear you're learning to be a PHP programmer!\n";
echo "Why don't you type in your name for me:\n";
$name = trim(fgets(STDIN));

echo "\nThanks, " . $name . ", it's really nice to meet you.\n\n";

?>

Answer

Rikesh picture Rikesh · Jan 17, 2014

Just define STDIN constant at top of your file,

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