No you don't need the spaces: PHP is a free-form language, and you can write things just about any way you wish, as long as it all comes in the right order and you don't actually put spaces into keywords, variable names, etc.
It's usually just easier to read, that's all.
Your second problem is a HTML one. 'value' is an attribute of the <input> element. Attributes must always be quoted, in orer to say where they start and end. Without the quotes, your browser assumes that "bunny" is some new attribute (of the kind that doesn't need to take a value - like the "selected" and "checked" attributes of the <select> list and the checkboxes/radio-buttons, respectively). The browser will not recognise this new "bunny" attribute of the <input> element, but it will ignore it, on the basis that all browsers are designed to be future-proof in this respect: the "bunny" attribute may have been introduced since the browser was released.
So why does it work at all, if elements are always supposed to be quoted? Well, like I say, attributes should always be quoted, but many coders are extremely lazy, in this respect, and leave the quotes off. The browser is then designed to cope with this by taking whatever follows the equals sign, up to the first space, as the value of the attribute. It cannot also tell that "Bunny" is also part of that value, since without the quotes, that's the limit of its intelligence. After all, what if you were to have a element like this:
<input value="Please Type Here" type="text" name="user_input" id="user_input" onClick=""this.value=''" />
Let's leave the quotes off, and see what you get:
<input value=Please Type Here type=text name=user_input id=user_input onClick=this.value='' />
... an input element with two type attributes!
FWIW, many fairly ancient browsers, like the early netscapes will chock on unquoted element attributes (in response to which, those people who have the temerity to call themselves 'programmers', and yet cannot be arsed to use the quote key, would blame the browser. Such people can and must be driven out of our industry, of course, before they convince bosses around the world, that they can replace all their real programmers, with people who will work all hours in return for bananas and free tea, and never buy computer books.)
Hope that's clear.
Take it easy,
Dan
"If Darl McBride was in charge, he'd probably make marriage unconstitutional too, since clearly it de-emphasizes the commercial nature of normal human interaction, and is a major impediment to the commercial growth of prostitution."
|