The CI framework supports two implementation methods: $ _ GET _ php instance

Source: Internet
Author: User
This article mainly introduces two CI frameworks that support $ _ GET. The example analyzes the implementation skills of get and pathinfo methods, for more information about how to use the CI framework to support $ _ GET, see the following example. We will share this with you for your reference. The details are as follows:

First, 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 that exceed the URI as parameters to the method. Go to the manual: CI framework Chinese manual

As follows: localhost/index. php/func/a/B

The php code in the Controller method is as follows:

<? Phpclass Jb51 extends CI_Controller {public function func ($ x, $ y) {echo $ x; echo $ y ;}}?>

As shown above: a and B are passed to the func method.

2. As you can imagine, if your parameter is too long, this method will definitely not work. OK, so do this:

Set 'uri _ Protocol' in config. php

$ Config ['uri _ Protocol'] = "PATH_INFO ";

Add

Parse_str ($ _ SERVER ['query _ string'], $ _ GET );

In this way, you can easily use index. php/func? X = a & y = B.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.