I am generating a string for placeholder dynamically via PHP echo function & if I don't put quotes around PHP tags the output only takes the first word of the string. Why so?
placeholder=<?php echo "Hello World"?>
placeholder="<?php echo "Hello World"?>"
This is due to how the
placeholder attribute is constructed.
You should conform to the standard of putting your value in between quotation marks (see this example as proof).
It requires the values to be put in between quotations if you wish to add spaces to your value.
So imagine when you do this:
<input type="text" placeholder=<?php echo "Hello World"?> >
You are returning this in the HTML file:
<input type="text" placeholder=Hello World >
It reads 'Hello' as it's value and then HTML sees 'World' as another attribute. This is why you need to put your value in between quotes to signify that the entire string is apart of the