Home >Backend Development >PHP Tutorial >The CI framework supports two implementation methods of $_GET, ci_get_PHP tutorial
This article describes the examples of CI framework supporting two implementation methods of $_GET. Share it with everyone for your reference, the details are as follows:
First of all, the ci framework supports GET after 2.0, so there is no pressure to use it!
1. Use get to pass parameters:
CI will automatically pass the two parts beyond the URI as parameters to the method. You can read the manual: CI Framework Chinese Manual
As follows: localhost/index.php/jb51/func/a/b
Then the method php code in the controller is as follows:
<?php class Jb51 extends CI_Controller { public function func($x, $y) { echo $x; echo $y; } } ?>
As above: a and b are passed to the func method
2. Imagine, if your parameters are very long, this method will definitely not work. OK, here’s how to do it:
In config.php, set 'uri_protocol' to
$config['uri_protocol'] = "PATH_INFO";
Add
before using $_GETparse_str($_SERVER['QUERY_STRING'], $_GET);
This way you can easily pass parameters using index.php/jb51/func?x=a&y=b.
Readers who are interested in more CodeIgniter related content can check out the special topics of this site: "codeigniter introductory tutorial", "CI (CodeIgniter) framework advanced tutorial", "php excellent development framework summary", "ThinkPHP introductory tutorial", "Summary of Common Methods in ThinkPHP", "Introduction Tutorial on Zend FrameWork Framework", "Introduction Tutorial on PHP Object-Oriented Programming", "Introduction Tutorial on PHP MySQL Database Operation" and "Summary of Common PHP Database Operation Skills"
I hope this article will be helpful to everyone’s PHP program design based on the CodeIgniter framework.