+ 6

How to input the number in php?

I tried to input the number through readline() function but it doesn't work.

8th Apr 2023, 3:45 PM
Sakshi [Offline 🙃]
Sakshi [Offline 🙃] - avatar
16 Réponses
+ 7
<html> <body> <form action="site.php" method="get"> Name: <input type="text" name="username"> <br> Age: <input type="number" name="age"> <input type="submit" name="submit" value="send"> </form> <br> <?php if(isset($_GET["submit"])){ echo "Your name is " . $_GET["username"] . ",<br>"; echo "You are " . $_GET["age"] . "."; } ?> </body> </html>
8th Apr 2023, 5:39 PM
JaScript
JaScript - avatar
+ 7
JaScript hmm, that's really sad btw thank you bro for helping and give the information.
8th Apr 2023, 6:17 PM
Sakshi [Offline 🙃]
Sakshi [Offline 🙃] - avatar
+ 7
˹ᴅᴇᴠᴇʟᴏᴘᴇʀ ᴛᴧɴᴊᴇᴅ˼ I already tried don't work in sololearn
10th Apr 2023, 8:09 AM
Sakshi [Offline 🙃]
Sakshi [Offline 🙃] - avatar
+ 6
as I remember sololearn doesn't have a console for php so php -a for interactive tools won't work but you can try echo '<script>document.write(prompt())</script>'; a little hybrid mixture
8th Apr 2023, 4:20 PM
Just Some Random Guy
Just Some Random Guy - avatar
+ 6
Snehil bro if I want to take input number like this:- $a = readline () Then how can I input like this?
8th Apr 2023, 4:31 PM
Sakshi [Offline 🙃]
Sakshi [Offline 🙃] - avatar
+ 6
Snehil hmm, it means we can't take input in easy way, btw thank you for the information.
8th Apr 2023, 5:23 PM
Sakshi [Offline 🙃]
Sakshi [Offline 🙃] - avatar
+ 6
Unfortunatelly SL do not support php.
8th Apr 2023, 6:02 PM
JaScript
JaScript - avatar
+ 6
You are welcome Sakshi By the way in php console you could input a number with: (int)readline(“please enter a number“)
8th Apr 2023, 7:12 PM
JaScript
JaScript - avatar
+ 6
Волгина Варвара I tried don't work in sololearn
10th Apr 2023, 8:10 AM
Sakshi [Offline 🙃]
Sakshi [Offline 🙃] - avatar
8th Apr 2023, 5:57 PM
Sakshi [Offline 🙃]
Sakshi [Offline 🙃] - avatar
+ 5
JaScript Yah I know bro, thank you 😊
8th Apr 2023, 7:15 PM
Sakshi [Offline 🙃]
Sakshi [Offline 🙃] - avatar
+ 3
that works in console(CLI) not on web page
8th Apr 2023, 4:34 PM
Just Some Random Guy
Just Some Random Guy - avatar
+ 3
https://code.sololearn.com/wmzkuHp2LaTR/?ref=app I tried accessing CLI input and I was successful in that but the machine didn't allowed user to give input u can see the code
8th Apr 2023, 4:47 PM
Just Some Random Guy
Just Some Random Guy - avatar
+ 3
Using the readline function: If you want to prompt the user to enter a number from the command line, you can use the readline function, like this: $number = readline("Enter a number: ");
9th Apr 2023, 10:02 PM
˹ᴅᴇᴠᴇʟᴏᴘᴇʀ ᴛᴧɴᴊᴇᴅ˼
˹ᴅᴇᴠᴇʟᴏᴘᴇʀ ᴛᴧɴᴊᴇᴅ˼ - avatar
+ 2
$number = readline();
10th Apr 2023, 8:09 AM
Волгина Варвара
Волгина Варвара - avatar
0
readline() will work when you running php in cmd/termux On Web/localhost uses make request $num = $_REQUEST['num'] then yourfilename.php?num=YourNumber?
25th Oct 2023, 4:33 AM
Satyam Verma
Satyam Verma - avatar