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


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


6 Answers

New Answer


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:


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");"


Faisal Thanks.


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.


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


Faisal so you can have all your php in different files?