Welcome Guest, Not a member yet? Register   Sign In
$_GET values

I have such URL
how can i get value of pfid?

$_GET is empty...

I think everything after the ? MIGHT be set as a segment
$vars = parse_str($this->input->segment(3));
echo $vars['pfid'];
Just not 100% sure if that url will be allowed or not

[eluser]Craig A Rodway[/eluser]
The $_GET variable is not allowed/supported. from the User Guide - Security.

Quote:GET, POST, and COOKIE Data

GET data is simply disallowed by CodeIgniter since the system utilizes URI segments rather than traditional URL query strings (unless you have the query string option enabled in your config file). The global GET array is unset by the Input class during system initialization.

Interesting thread here also.

in config.php set query-strings to true and your GET variables will be available again.

Why not just use CodeIgniter's native conventions and do it like this:


$uri = $this->uri->uri_to_assoc(3);

Then your controller will have access to the following variables:


There are reasons why $_GET variables are by default disabled in CI.

I have the same question couple months ago:

I know this way : /controller/view/TB_iframe/true/height/400/width/800/pfid/1 might solve the problem, but then it make the url looks ugly - especially when u have a a lot of values in ur url ...

as woopsicle said, change the setting in config file it will then solve ur problem .. but i read somewhere else saying that it's not encourage to do so (I dont know why) .. im still in doubt !!

[eluser]Chris Newton[/eluser]
Why would it matter if the URL looks ugly? It looks better to robots if it's not a query string & casual users don't understand what all the ? and & stuff is anyway.

If ugliness really matters, you could pass it as a $_POST anyway, which is pretty simple.

I personally really LIKE using query strings, but disabling $_GET is good for site security, so I use the segments. I HATE calling things by segment numbers though, so I use this to get and set URI values.


Hello all. I'm having a similar issue. I too have a url, it must use get because it's a 3rd party fax service that is sending back results, and this is the only way they send it. You give them a url, and they append ?param1=xxx&param2=xxx to it. So like this:

http://www.mydomain.com/index.php/engine...08/20/2010 01:07:26 PM &destination=12676017739&pages=1&duration=22&userjobcode=b6cab731-e620-3673-bc89-4c6d72a1870f&greenfaxreferenceid=79264266&cost=0.07

I've added &\= to permitted_uri_chars so that if I take out the ? in the above link, it works by getting the uri segment and parsing it, but with the ? mark in there (I'm told they can't remove it though, their system just takes the customer given url and adds the rest) I get a 404 not found, even if enable_query_strings is set to true. Any ideas? What sucks is this is the ONLY case in our app where I need to worry about receiving GET parameters.

This has been discussed I can't remember how many times. Use the search option (hint: search for allow_get_array ).

[eluser]Chris Newton[/eluser]
You can also do what I've done before... use a special PHP file outside of CI that does little but parse the get variables out of the URL that's passed in, then send them over to the CI app.

Theme © iAndrew 2016 - Forum software by © MyBB