Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/254415-php-adding-to-input/#findComment-1304501
Share on other sites

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

 

Link to comment
https://forums.phpfreaks.com/topic/254415-php-adding-to-input/#findComment-1304502
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/254415-php-adding-to-input/#findComment-1304503
Share on other sites

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

 

 

Link to comment
https://forums.phpfreaks.com/topic/254415-php-adding-to-input/#findComment-1304504
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/254415-php-adding-to-input/#findComment-1304511
Share on other sites

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!!

Link to comment
https://forums.phpfreaks.com/topic/254415-php-adding-to-input/#findComment-1304515
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/254415-php-adding-to-input/#findComment-1304521
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.