php - Why echo's output needs to be separately put in quotes for placeholder's string in input field? -


i generating string placeholder dynamically via php echo function & if don't put quotes around php tags output takes first word of string. why so?

  1. placeholder=<?php echo "hello world"?>
    outputs hello in input field
  2. placeholder="<?php echo "hello world"?>"(note quotes around php tags)
    outputs hello world in input field.

same happens value attribute of input field.

this due how placeholder attribute constructed.

you should conform standard of putting value in between quotation marks (see this example proof).

it requires values put in between quotations if wish add spaces value.

so imagine when this:

<input type="text" placeholder=<?php echo "hello world"?> > 

you returning in html file:

<input type="text" placeholder=hello world > 

it reads 'hello' it's value , html sees 'world' attribute. why need put value in between quotes signify entire string apart of placeholder attribute.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -