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