My Blog

How to get input from keyboard using php ?

  Al-Amin Sarker  |   29 Apr, 2017 |   PHP |   view 89 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.

facebook box