The Blog

Reading $_GET variable in CODEIGNITER

14 Ago 10

There are multiple solutions out there but i did create my own.

It’s simple as 1,2,3. Hope it helps.

[sourcecode lang=”php”]
// CODEIGNITER HACK
$tmp = explode(‘?’,$_SERVER[‘REQUEST_URI’]);
$tmp = explode(‘&’, $tmp[1]);

foreach($tmp as $keyval) {
$tmpAppoggio = explode(‘=’, $keyval);
$_GET[urldecode($tmpAppoggio[0])]=urldecode($tmpAppoggio[1]);
}
// end of codeigniter hack
[/sourcecode]

Comments

  • Thanks… may I know what is for this script..because I receive this link in my blog…!! Peace ๐Ÿ™‚

  • andrea

    It s tor handling Get variables using codeigniter. The mvc framework

  • Simplest way:
    system/config/config.php
    Line 44: $config[‘uri_protocol’] = “PATH_INFO”;
    Line 151: $config[‘enable_query_strings’] = TRUE;

  • Yes sebastiano that’s another simple solution..

    If you have to manage the get variable on every controller than you’ll prefer your solution instead of mine.

    In my scenario, since i only need the GET variable in one controller, i prefer to use my hack.

  • Thanks, this is exactly what I need as I only want GET variables in several controllers. My best example is search, because I like letting users pass the URL of search results around.

  • ไปŽ็™พๅบฆๆœๅˆฐไฝ ๅšๅฎข

  • It s tor handling Get variables using codeigniter. The mvc framework

  • tks! it works and is very simple!