Im new to PHP and I am trying to read user input in my code but im getting the error: Use of undefined constant STDIN - assumed 'STDIN'
<?php
echo "<h1>Armstrong number</h1>";
echo "Enter number: ";
fscanf(STDIN, "%d", $input); //Error Line
$n=$input;
$sum=0;
while($n != 0)
{
$rem = $n % 10;
$sum = $sum + $rem*$rem*$rem;
$n = $n / 10;
}
if ($input == $sum)
echo $input." entered is an armstrong no.";
else
echo $input." isnt an armstrong no.";
?>
``
Because your conts "STDIN" isn't defined. For example, you can try this:
$handle = fopen("your_file.txt", "r");
define('STDIN', $handle);
and your code below
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.