Server.UrlEncode from Asp.net to codeigniter |
[eluser]bleu[/eluser]
i am using this in my asp.net website when outputting a value from the database into a link Code: <a href="+ Server.UrlEncode(value_to_be_encoded)+"></a> What will be the codeigniter version of this
[eluser]achilleusrage[/eluser]
For security reasons, CodeIgniter is strict (by default) about which characters you can put in your URI strings. See: http://ellislab.com/codeigniter/user-gui...urity.html and http://ellislab.com/codeigniter/user-gui...urity.html You can allow other characters and even enable query strings but that's at your own risk. Otherwise, the PHP equivalent to encode characters is: Code: urlencode($str);
[eluser]bleu[/eluser]
[quote author="achilleusrage" date="1331301630"]For security reasons, CodeIgniter is strict (by default) about which characters you can put in your URI strings. See: http://ellislab.com/codeigniter/user-gui...urity.html and http://ellislab.com/codeigniter/user-gui...urity.html You can allow other characters and even enable query strings but that's at your own risk. Otherwise, the PHP equivalent to encode characters is: Code: urlencode($str); When I am adding Code: $str="How are you &x=5"; it is giving me this url Code: How+are+you+&x=5 Code: An Error Was Encountered How can I solve this? The data will come from the database and will then be encoded in the url
[eluser]achilleusrage[/eluser]
Limiting characters in URI's is an important security measure. You should really look into doing something else with the data in your URIs (like, strip special characters and replace whitespace with underscores (_)). Example: http://yourwebsiteaddress/how_are_you/x/5 But, with that warning, you can allow other characters in your config.php file: Code: /* ...if indeed, as the comments above suggest, you are insane. :-) |
Welcome Guest, Not a member yet? Register Sign In |