doushou1298 2017-06-04 09:45
浏览 86
已采纳

PHP问题:动态加载HTML - 在PHP中设置输入值 - 存储在PHP变量中[重复]

This question already has an answer here:

[ ISSUE ]: I have created a function in php that dynamically loads html blocks of code depending on the parameters I pass, the function will be utilized to load text-boxes in one page and in another page to display the answers retrieved from the text-boxes. Example:

function chapterOne($param1, $param2) {
    echo 'Welcome';
    echo 'My name is '. $param1;
    echo 'I am from ' . $param2;
}

# The form is going to return $name or $loc values if
# any text-box is forgotten empty when form is submitted
# ---------------------------------------------------------
$p1 = '<input type="text" placeholder="name" value="<?php echo $name; ?>" >';
$p2 = '<input type="text" placeholder="loc"  value="<?php echo $loc;  ?>" >';
echo chapterOne($p1,$p2);

The issue is that the value shows the php code instead of the placeholder, but only happens dynamically, when I test regular it works. Any thoughts or feedback how to overcome this issue?

Textbox example:

enter image description here

</div>
  • 写回答

2条回答 默认 最新

  • dongxie548548 2017-06-04 09:56
    关注

    Use Concatenation .

    $p1 = '<input type="text" placeholder="name" value="' . $name . '" >';
    $p2 = '<input type="text" placeholder="loc"  value="' . $loc . '" >';
    echo chapterOne($p1,$p2);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 MATLAB怎么通过柱坐标变换画开口是圆形的旋转抛物面?
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥30 用arduino开发esp32控制ps2手柄一直报错
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题