CodeIgniter Methods
In the previous Hello World model, our technique name is record(). As a matter of course Controller consistently calls record technique. On the off chance that you need an alternate strategy, at that point compose it in the Controller's record and indicate its name while calling the capacity.
Take a gander at the URL, there is no strategy name is referenced. Thus, as a matter of course list technique is stacked.
Method other than index()
Here, we have referenced a strategy called newFunction(). Presently we need to call this new technique to run our program.
Make a controller page Hello.php in application/controllers.
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Hello extends CI_Controller {
public function newfunction()
{
$this->load->view('hello_world');
}
}
?>
Take a gander at the above preview, we have made a capacity newFunction.
Make a view page hello_world.php in application/sees.
<!DOCTYPE html>
<html>
<head>
<title>Hello World Example</title>
</head>
<body>
<p>Hello World!!</p>
</body>
</html>
To run this program on our program, follow way
http://localhost/CodeIgniter/index.php/Hello/newFunction
Take a gander at the above preview, we made the Controller's capacity as newFunction and indicated it in the URL after Controller's name.
Here,/index.php/Hello is Controller's name.
What's more,/newFunction is the Function name.
Remapping Method Calls
Second section of URI figures out which technique is being called. In the event that you need to supersede it you can utilize _remap() strategy.
In the event that you have referenced _remap() technique in your controllers, it will consistently get called regardless of whether URI is extraordinary. It supersedes the URI.
public function _remap($methodName)
{
if ($methodName === 'a_method')
{
$this->method();
}
else
{
$this->defaultMethod();
}
}