Al-Amin's Blog

How to get input from keyboard using php ?

  Al-Amin Sarker  |   29 Apr, 2017 |   PHP |   view 763 times

PHP is an open source programming language. You can get any key from your keyboard using this langulage. Now I'll show you how to get input from keyboard. So, stay with me and follow this bellow steps:

  1. First open your control panel
  2. Go and hit system and security option.
  3. Then hit system tab.
  4. Hit advanced system settings tab on your left sidebar menu.
  5. You should see a new popup window and hit advanced tab. Now you see environment variables towards the bottom of the window.
  6. Now copy your path in the user variables list.
  7. Append your PHP Path (E:\xampp\php) to your PATH variable, separated from the already existing string by a semi colon.
  8. Click OK.

[N:B: Make sure that your PHP folder has the php.exe file]
Now write some PHP code and save it by hello.php name on your server location like E:\xampp\htdocs\hello.php

								echo "Enter your number : ";

								/** Store your standard input */
								$no = ( int )fgets( STDIN );

								echo ( $no >= 0 ) ? "Result is = " .$no : "Oops! Something was wrong.";


Now Open your terminal Command Prompt (CMD) and access to your PHP file where you stored in your machine.

Subscribe to newsletter

About Al-Amin Sarker

Profile Picture

Al-Amin Sarker is a Bangladesh times best Web Engineer. He helps to build web based software. He studied at Computer Science and Engineering in Rajshahi University, Rajshahi, Bangladesh. He has more than 6 years of experience on building robust and scalable web applications (not websites) with cutting edge technologies Continue reading...

Do you love my source code ?

Hire me to Develop

Do you want me to
Develop at
Your Software ?
Click here to Hire

facebook box