Routing in CodeIgniter
contain
done URL routing
from controller
from view
in controller
from function and function with parameters
(missing parameter)
in view
creating a variable and passing it into the controller
URL routing
1 from controller
consider the hello.php file and it must be in controller folder in codeigniter and created public function first with two parameters $p1,$p2
after modification call the URL path as localhost/ci/index.php/hello/fist/one/two then result would be shown as
my parameter are : one and two
after calling two parameter inside URL one parameter assign it self in parameter and other called by URL
then again call URL with one function localhost/ci/index.php/hello/fist/one out put become
my parameter are : one and two
again called index function in same hello.php as special cases
with calling class name localhost/ci/index.php/hello then out put become
this is special method
check about the situation about missing parameter in URL statement then call the URL with non parameter as
localhost/ci/index.php/hello/fist
consider we created php file in view named as first.php
then if we want route in view we have to create function in hello.php
public function first($value)
{
$data =array("name" => $value);
$this ->load ->view('first',$data);
}
here we parse the values from hello.php to first.php in view.
http://localhost/codi/index.php/hello/first/jack
then output will be
this is the first in view
hello,jack
thank you

No comments:
Post a Comment