rowrow rowrow - 5 months ago 8
PHP Question

setting value of attribute using php echo does not work

I tried the following code:

<input name="first-name" type="text" class="form-control"
placeholder=<?php echo (form_error('birth-date') !== '') ? 'Please enter name' : 'Enter name'; ?> >


However, the output is only either "Please" or "Enter". It doesn't show the rest of the characters after first space.

What am I doing wrong?

Jah Jah
Answer

you are missing the "

<input name="first-name" type="text" class="form-control" 
       placeholder="<?php echo (form_error('birth-date') !== '') ? 'PLease enter name' : 'Enter name'; ?>">