User input in PHP. | Sololearn: Learn to code for FREE!

+7

User input in PHP.

I have just started learning php.I am confused about taking some input from user like we do in python or java.

6/2/2018 3:38:39 PM

Mitali

6 Answers

New Answer

+14

PHP is a little weird in the sense that it relies on HTML to gather all of its information and data, meaning that you can't take user input directly in from your PHP code. The way that you do so is by implementing a form within your HTML code and linking it to your PHP file (because of this, you can't really take user input with PHP on Sololearn). Hope this helped! d:

+9

Actually, You CAN use the command line to have input from. It is like any other language, You have STDIN. If You want to read data sent via the network, The best option is to use POSTMAN or create a simple page which will utilize methods such as (ofc) GET, POST, PUT and handle them. To create a handle for STDIN use: "fopen ("php://stdin","r");"

+6

Faisal Thanks.

+4

You can also use ajax (a javascript method which can send information to a specific url without reloading the page). That can be really helpful.

+2

Spaarwiel Yeah, PHP works better (for what I know) when separated by a file

0

Faisal so you can have all your php in different files? https://www.sololearn.com/discuss/1325020/?ref=app