Reputation: 609
This is a strange problem... wondering if anyone has run into this? I have php embedded into a standard HTML page, and I'm using the php to insert data into various areas of a form on the page. I'm using Bootstrap for the form elements.
I set a php variable such as this:
$myVar = "This is the text";
And down in the page, here is what the code looks like for the Bootstrap input:
<div class="input-field3"><input type="text" class="form-control" id="my-var" placeholder=<?php echo $myVar ?>></div>
When this page is viewed, only the word "This" is displayed in the Input. The results are the same if I change from placeholder to value. No matter how long I make the first word in the variable, it will display everything up to the first space. I've also tried it with single or double quotes around the variable.
When I look at the page source, it appears correct, like this:
<div class="input-field3"><input type="text" class="form-control" id="my-var" placeholder=This is the text></div>
Any ideas or solutions would be appreciated!
Upvotes: 0
Views: 269
Reputation: 145
It should be like this
<div class="input-field3"><input type="text" class="form-control" id="my-var" placeholder="<?php echo $myVar ?>"></div>
Upvotes: 1
Reputation: 3470
You don't have quotes around the value in the generated HTML.
Try this instead:
<div class="input-field3"><input type="text" class="form-control" id="my-var" placeholder="<?php echo $myVar ?>"></div>
Upvotes: 3