codeigniter routes with parameters

Today, We want to share with you codeigniter routes optional parameter.In this post we will show you codeigniter route optional parameter, hear for codeigniter 4 routes we will give you demo and example for implement.In this post, we will learn about Codeigniter 3 Get All Routes Using Controller with an example.

Codeigniter controllers subfolders

Codeigniter controllers subfolders Example

<?php 
defined('BASEPATH') OR exit('No direct script access allowed'); 

class Login extends CI_Controller { 	 	

	public function index()
	{ 		

		$this->load->view('login_view');

	}
}

nice clean URL of:

Read Also:  How to Integrate PayPal Payment Gateway in PHP?

http://pakainfo.com/account/manage/4123245/jakub

// sub directories

/application/controllers/account/manage.php

Understand your route

/application/config/routes.php

$route['account/manage/(:num)/(:any)']  = "account/manage/index/$1/$2";

manage.php controller

<?php
class Manage extends CI_Controller {
 
    public function index($id, $membername)
    {
        // do something here with the two values
    }
 
}
?>

I hope you get an idea about dynamic routing in codeigniter.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Read Also:  How to fetch image from database in php ?

Related FAQ

Here are some more FAQ related to this Article:

  1. Read Also:  codeigniter Controller pass parameter route Function
  2. Read Also:  Get Current Url Parameter using Laravel
  3. Read Also:  CodeIgniter Beginners Tutorial Step by Step
  4. Read Also:  Retrieve last insert id by Eloquent in Laravel 6
  5. Read Also:  PHP download file from url using curl example
  6. Read Also:  PHP Format File Size Convert KB MB GB
  7. Read Also:  Laravel 6 Eloquent Global Scope Tutorial Example
  8. Read Also:  How to Get Yii last inserted ID from database
  9. Read Also:  WordPress Force SSL HTTPS On All Pages
  10. Read Also:  codeigniter Controller pass parameter route Function
CLOSEX