echo 在要作为 echo 输出的值内 PHP

请问,我们如何才能将 echo 放入一个受回显影响的变量中?


这是代码。


我试图把在values=""中$user['firstname']和$user['lastname']


while($row = sqlsrv_fetch_array($query, SQLSRV_FETCH_ASSOC)){

$out .= "

<div class='form-group' > <!-- hidden-->

<label for='postedby' class='col-sm-3 control-label'>Posted By</label>

<div class='col-sm-9'>

<input type='text' class='form-control' id='postedby' name='postedby' 

value='$user['firstname'] $user['lastname']' style='text-transform:uppercase;width:90%' >

</div></div>

";

    }


    echo $out;

?>

有没有办法做到这一点?回声里面回声?


开满天机
浏览 111回答 2
2回答

蝴蝶刀刀

尝试这个。$out = '';while($row = sqlsrv_fetch_array($query, SQLSRV_FETCH_ASSOC)){$out .= '<div class="form-group" > <!-- hidden--><label for="postedby" class="col-sm-3 control-label">Posted By</label><div class="col-sm-9"><input type="text" class="form-control" id="postedby" name="postedby"&nbsp;value="'.$user['firstname'].' '.$user['lastname'].'" style="text-transform:uppercase;width:90%"></div></div>';&nbsp; &nbsp; }&nbsp; &nbsp; echo $out;您对CONCAT名字和姓氏。

小怪兽爱吃肉

只需在每个变量周围加上括号,剩下的由 php 完成。while($row = sqlsrv_fetch_array($query, SQLSRV_FETCH_ASSOC)){&nbsp;&nbsp; &nbsp; $out .= " <div class='form-group' >&nbsp; &nbsp; &nbsp; &nbsp;<!-- hidden-->&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<label for='postedby' class='col-sm-3 control-label'>Posted By</label>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<div class='col-sm-9'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<input type='text' class='form-control' id='postedby' name='postedby' value='{$user['firstname']} {$user['lastname']}' style='text-transform:uppercase;width:90%' >&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div>&nbsp; &nbsp; &nbsp; &nbsp;</div> ";}&nbsp;echo $out; ?>
打开App,查看更多内容
随时随地看视频慕课网APP