CodeIgniter Forums
$this->uri->uri_to_assoc() Replaces Period "." (dot) With An Underscore "_" - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: $this->uri->uri_to_assoc() Replaces Period "." (dot) With An Underscore "_" (/showthread.php?tid=33754)



$this->uri->uri_to_assoc() Replaces Period "." (dot) With An Underscore "_" - El Forum - 09-07-2010

[eluser]morehawes[/eluser]
Hi all, this has got me truely stumped so I am wondering if anyone has any ideas! Getting URI data using uri_to_assoc is replacing "." (period) with "_" (underscore). For example this basic controller :

Code:
<?php class Test extends Controller {
    function get_data() {
        echo '<pre>';
        print_r($this->uri->uri_to_assoc());
        echo '</pre>';
    }
}

When given the URL "http://www.myurl.com/test/get_data/username/morehawes.test" outputs this :

Code:
Array
(
    [username] => morehawes_test
)

I have also checked my config to ensure periods are allowed :

Code:
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';

I would really really appreciate it if anyone could help with this Smile

Many thanks!


$this->uri->uri_to_assoc() Replaces Period "." (dot) With An Underscore "_" - El Forum - 09-07-2010

[eluser]danmontgomery[/eluser]
This is PHP functionality, it happens well before the uri gets to codeigniter.

http://us.php.net/variables.external
[quote]The experienced may note that the actual variable names sent by the browser contains a period rather than an underscore, but PHP converts the period to an underscore automatically.


$this->uri->uri_to_assoc() Replaces Period "." (dot) With An Underscore "_" - El Forum - 09-07-2010

[eluser]morehawes[/eluser]
Hi noctrum, thanks for your swift reply. This is a big help - I was not aware of this behaviour. Infact on my localhost this is not happening at all, only on my hosting. Do you think this is being caused by register_globals being on? (off in my locahost and on in my hosting)

This is causing a big problem with my application so if this is the case I may try and get my hosting company to change this (using php_flag register_globals off in my htaccess file doesn't seem to work)


$this->uri->uri_to_assoc() Replaces Period "." (dot) With An Underscore "_" - El Forum - 09-07-2010

[eluser]morehawes[/eluser]
Hi again, just to let you know that I have fixed the problem by figuring out a work-around. Thanks again for your help Smile