Home >Backend Development >PHP Tutorial >The CI framework supports two implementation methods of $_GET, ci_get_PHP tutorial

The CI framework supports two implementation methods of $_GET, ci_get_PHP tutorial

WBOY
WBOYOriginal
2016-07-12 08:52:12929browse

CI framework supports two implementation methods of $_GET, ci_get

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:

<&#63;php
class Jb51 extends CI_Controller {
 public function func($x, $y)
 {
  echo $x;
  echo $y;
 }
}
&#63;>

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 $_GET
parse_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.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1127849.htmlTechArticleThe CI framework supports two implementation methods of $_GET, ci_get. This article describes the two implementation methods of $_GET supported by the CI framework. Implementation method. Share it with everyone for your reference, the details are as follows: First, the ci framework is...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn