1

I tried the following, and it shows an empty text area, the value isn't displayed:

    <input type="textarea" class="class1" name="name1" placeholder="<?= $val1?>" /> 

Any thoughts on what should be done so it will work?

Update: It is now working, the value was empty, therefore text area didn't show anything. The code can be used safely.

10
  • 4
    Is PHP short_open_tag enabled? What does the page source look like after you render it? Commented Jan 26, 2012 at 19:24
  • "it didn't work". In what way didn't it work? Was the value present in the rendered HTML? Were there any PHP error messages? Commented Jan 26, 2012 at 19:24
  • 1
    Describe what you mean by "didn't work". Is there an error on the page? Is the html attribute empty? Are you sure that $val1 contains a value? Commented Jan 26, 2012 at 19:25
  • 1
    @Asaph - thanks! the value was indeed empty. It is now showing the value Commented Jan 26, 2012 at 19:30
  • 1
    the answer is actually in the comments here by @Asaph Commented Jan 26, 2012 at 21:40

4 Answers 4

3
<input type="textarea" class="class1" name="name1" placeholder="<?php echo $val1; ?>" />

There is no such input type attribute as textarea.

Do you mean:

<textarea class="class1" name="name1" placeholder="<?php echo $val1; ?>"></textarea>
Sign up to request clarification or add additional context in comments.

3 Comments

textarea is not a valid value for the type property of the input tag.
Probably because before @Phoenix's edit, your answer didn't really read like an answer.
It seems to be working just fine with <input type="textarea"
3

if $val1 is not null, i think the problem is short tag (<?= ?>).

You can override this config, at the top of file, put this line to enable short tag:

ini_set('short_open_tag',1);

Comments

2

Make sure that $val1 actually contains a non-empty value. If it does, your code should create a non-empty placeholder attribute.

Comments

0

Check whether the variable is empty (as @Asaph suggested in his comment). Entered a value and now it is working just fine.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.