Retrieve HTML input values ​​using an interface (like Laravel)
P粉514001887
P粉514001887 2024-03-30 19:49:04
0
1
454

I want to use interface methods like request to get HTML data. If anyone knows please explain.

I want to get output like this! Please help in writing a sample Request php interface.

My real scenario is that I have a controller that has a create function. The create function passes parameters as Request class. I want to access the HTML input as I mentioned in the question. This is my problem.

<input name="inputname">
<input name="anotherinputname">
public function create(Request $request) {
   echo $request->inputname;
   echo $request->anotherinputname;
}

So please help make the Request class. Thanks

P粉514001887
P粉514001887

reply all(1)
P粉985686557

It doesn't work like you think. Laravel uses dependency injection. You can define a Request class and map POST data to properties in its constructor. Something like this:

class Request {
    public $get;
    public $post;

    public function __construct() {
        $this->get = $_GET;
        $this->post = $_POST;
    }
}

You can then access the POST data via:

$request->post['anotherinputname'];
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template