What is the difference between $this->input->post() and $_POST[] in codeigniter?
$_POST is a native PHP superglobal
$this->input->post() is a method of the CodeIgniter Input Class
From their documentation:
The Input Class serves two purposes:
- It pre-processes global input data for security.
- It provides some helper methods for fetching input data and pre-processing it.
So, $this->input->post() is a helper method provided by CodeIgniter. Instead of having to check if a value is set in $_POST, retrieve it and then protect the value from security issues such as XSS attacks, you simply use $this->input->post() and let it do the work for you.
This the whole point to using a framework. It takes care of details like this for you, so you can focus on implementing business logic.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With