Codeigniter 3 Pass anything in query string

To pass anything in the query string using CodeIgniter 3, you can follow these steps:

  1. Open the controller file where you want to handle the query string data.

  2. Use the CodeIgniter's URI Class to retrieve the query string parameters. This class provides methods to interact with the URI segments and retrieve the query string.

  3. Load the URI library by adding the following line of code in your controller file:

  1. To retrieve the query string parameters, you can use the uri_string() method of the URI Class. This method returns the query string portion of the URL. For example, if the URL is "", the uri_string() method will return "param1=value1&param2=value2".

  2. You can then use the uri_string() method to parse the query string and extract the individual parameters. CodeIgniter provides a helper function called uri_string_to_assoc() that converts the query string into an associative array.

Here's an example of how you can pass anything in the query string using CodeIgniter 3:

// Controller file
class MyController extends CI_Controller {
    public function index() {

        $query_string = $this->uri->uri_string();
        $params = $this->uri->uri_string_to_assoc($query_string);

        // Access the query string parameters
        $param1 = $params['param1'];
        $param2 = $params['param2'];

        // Use the parameters as needed
        // ...

In this example, the index() method of the MyController class receives the query string parameters param1 and param2. You can access these parameters using the $params array.

That's it! You have successfully passed anything in the query string using CodeIgniter 3.