Monkuar Posted January 5, 2012 Share Posted January 5, 2012 need to add $ibforums->input['[u'] != "") something like that i need to add $_GET['']; but it's not working when i use &= do ineed to use html entities? Quote Link to comment https://forums.phpfreaks.com/topic/254415-php-adding-to-input/ Share on other sites More sharing options...
Adam Posted January 5, 2012 Share Posted January 5, 2012 I don't follow your post at all.. but if you've added [] to an input, you've turned the data into an array. To access this in the PHP, you just access it as you would before. Instead of getting a string back though, you get an array of strings. You'll need to read more about arrays in the manual if you don't understand. Quote Link to comment https://forums.phpfreaks.com/topic/254415-php-adding-to-input/#findComment-1304501 Share on other sites More sharing options...
Monkuar Posted January 5, 2012 Author Share Posted January 5, 2012 I don't follow your post at all.. but if you've added [] to an input, you've turned the data into an array. To access this in the PHP, you just access it as you would before. Instead of getting a string back though, you get an array of strings. You'll need to read more about arrays in the manual if you don't understand. i have my file name .php and i want to use $_GET['[u]']; and I Want tobeable to use &[u]=XXXX on my site Quote Link to comment https://forums.phpfreaks.com/topic/254415-php-adding-to-input/#findComment-1304502 Share on other sites More sharing options...
ManiacDan Posted January 5, 2012 Share Posted January 5, 2012 Ok, you can't do that. Look, if you have: <input type="text" name="data[u]" /> Then $_GET['data']['u'] will be the value of that input. An input name cannot start with a square bracket. A PHP variable name cannot start with a square bracket. Why do you believe you need to do this? Describe the actual problem. Quote Link to comment https://forums.phpfreaks.com/topic/254415-php-adding-to-input/#findComment-1304503 Share on other sites More sharing options...
Monkuar Posted January 5, 2012 Author Share Posted January 5, 2012 Ok, you can't do that. Look, if you have: <input type="text" name="data[u]" /> Then $_GET['data']['u'] will be the value of that input. An input name cannot start with a square bracket. A PHP variable name cannot start with a square bracket. Why do you believe you need to do this? Describe the actual problem. I want to do this because it would look awesome as a site url decoration.. I have my index.php set to [i].php and edited my apache config to read that as index and it works fine why cant i add the [ ] brackets to the input? im sure ican there has to be a way, lol Quote Link to comment https://forums.phpfreaks.com/topic/254415-php-adding-to-input/#findComment-1304504 Share on other sites More sharing options...
Philip Posted January 5, 2012 Share Posted January 5, 2012 [] cannot be used in the URL without escaping/encoding it Quote Link to comment https://forums.phpfreaks.com/topic/254415-php-adding-to-input/#findComment-1304507 Share on other sites More sharing options...
Monkuar Posted January 5, 2012 Author Share Posted January 5, 2012 [] cannot be used in the URL without escaping/encoding it thats what i wanna do with my input help? :shrug: Quote Link to comment https://forums.phpfreaks.com/topic/254415-php-adding-to-input/#findComment-1304510 Share on other sites More sharing options...
Philip Posted January 5, 2012 Share Posted January 5, 2012 You cannot use them in the way you want in the URL. It is against the specs: http://tools.ietf.org/html/rfc3986#section-2.2 The only time [ and ]'s are allowed within the URI is for IPs: A host identified by an Internet Protocol literal address, version 6 [RFC3513] or later, is distinguished by enclosing the IP literal within square brackets ("[" and "]"). This is the only place where square bracket characters are allowed in the URI syntax. In anticipation of future, as-yet-undefined IP literal address formats, an implementation may use an optional version flag to indicate such a format explicitly rather than rely on heuristic determination. IP-literal = "[" ( IPv6address / IPvFuture ) "]" I believe you can do this though: foo.php?x%5Bfoo%5D=bar would allow you to get $_GET['x[foo]']; But I know you wanted it all for looks, but thats a no-go on looks IMO. Quote Link to comment https://forums.phpfreaks.com/topic/254415-php-adding-to-input/#findComment-1304511 Share on other sites More sharing options...
Monkuar Posted January 5, 2012 Author Share Posted January 5, 2012 You cannot use them in the way you want in the URL. It is against the specs: http://tools.ietf.org/html/rfc3986#section-2.2 The only time [ and ]'s are allowed within the URI is for IPs: A host identified by an Internet Protocol literal address, version 6 [RFC3513] or later, is distinguished by enclosing the IP literal within square brackets ("[" and "]"). This is the only place where square bracket characters are allowed in the URI syntax. In anticipation of future, as-yet-undefined IP literal address formats, an implementation may use an optional version flag to indicate such a format explicitly rather than rely on heuristic determination. IP-literal = "[" ( IPv6address / IPvFuture ) "]" I believe you can do this though: foo.php?x%5Bfoo%5D=bar would allow you to get $_GET['x[foo]']; But I know you wanted it all for looks, but thats a no-go on looks IMO. eh i'lll just use my file name .php for now.. thanks tho php should add this future!! Quote Link to comment https://forums.phpfreaks.com/topic/254415-php-adding-to-input/#findComment-1304515 Share on other sites More sharing options...
Philip Posted January 5, 2012 Share Posted January 5, 2012 Do note that it isn't PHPs fault. This is a standard set by the IETF quite a while ago and likely never allow what you're wanting. Quote Link to comment https://forums.phpfreaks.com/topic/254415-php-adding-to-input/#findComment-1304518 Share on other sites More sharing options...
ManiacDan Posted January 5, 2012 Share Posted January 5, 2012 I think you're getting a little confused by what's going on here, so even though this topic is marked "solved" I'm going to explain it again: Square brackets are special characters. They are not valid for use in: - URLs - Field names - Variable Names - File Names It has nothing to do with PHP, it has nothing to do with form encoding, it has nothing to do with your personal project. It has everything to do with computers in general, and the governing bodies that regulate how the internet and programming languages work. Also, mod_rewrite can do all kinds of fun things to your URLs, go play with that instead. Quote Link to comment https://forums.phpfreaks.com/topic/254415-php-adding-to-input/#findComment-1304521 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.