Can <input> elements have capital letters and spaces in PHP

前端 未结 4 1310
感动是毒
感动是毒 2020-12-21 14:29

Do elements in forms need to be a single word, either in totality or using an underscore, or can they have spaces?



        
相关标签:
4条回答
  • 2020-12-21 15:09

    A form name attribute may contain spaces, but you will find that in PHP the spaces (and periods) are replaced with underscores in the $_GET / $_POST / $_REQUEST arrays:

    <pre><?php var_dump($_REQUEST, $_GET, $_POST); ?></pre>
    
    <form method="get">
        <input name="This is a name" value="This is a value" />
        <input type="submit" />
    </form>
    

    With either "get" or "post" methods, the input will be keyed This_is_a_name.

    Reference: PHP: Variables From External Sources (Note below example)

    0 讨论(0)
  • 2020-12-21 15:11

    Space should not be used, as they are replaced by _. You can use Underscore instead of space to avoid forceful replacement.

    0 讨论(0)
  • 2020-12-21 15:16

    They need to be a single word, but can have numbers and underscores.

    0 讨论(0)
  • 2020-12-21 15:27

    Yes, input in forms should be a single word. They can have underscores or numbers and they can also be Capital letters but there should be no space in the name you specify. Also make sure you don't enter special characters in name.

    0 讨论(0)
提交回复
热议问题