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 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试