html的value属性中的php代码

I have a html form with a textbox in which i want to pull the name of the person signed in to automatically be filled in the text box when the page loads. below is the code i am using.

<input type="text" autocomplete="off" name="createdby" id="createdby" value= <?= $first_name.' '.$last_name ?> readonly>

the issue is with the php code

   <?= $first_name.' '.$last_name ?>

Because of the space between .' ' . the last name does not show. however when i remove the space both the first name and the last name show but without any spaces. How do i pull both names from the database and have them separated

</div>

I believe it needs to look as follows:

<...value="<?= $first_name.' '.$last_name ?>" readonly>

You should use double quotes around your php tags.

implode() looks better then such concatenation:

implode(' ', array($first_name, $last_name));

Convert this:

<?= $first_name.' '.$last_name ?>

Into this:

<?php echo $first_name.' '.$last_name ?>

Or this if you want to simplify variables concatenation:

<?php echo “$first_name $last_name” ?>

Use the standard php tags and explicitly echo your values