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";
?>
It looks like you are trying to use a constant called
STDIN
, which does not exist.STDIN is used to get a currently open stream with fopen.
Using
STDIN
without a currently open stream would not work.I also believe that
STDIN
only works under cli, but am not 100% sure. If that is the case, use the same code as above, but replaceSTDIN
with$file
;Just define
STDIN
constant at top of your file,If you want your code to be executed properly with the "STDIN" Constant you have two options:
or :
The other option :
Will not work !! you may have to define the "STDIN" constant inside your code as mentioned above.
Try adding this on the top of your file