Textarea动态变量

时间:2017-07-16 17:26:46

标签: php html textarea

我想从textarea定义动态变量

<form>
<textarea name="dynamicText">Hello my name is [name]</textarea>
<button type="submit">Send</button>
</form>

Php代码示例

$text = $_POST['dynamicText'];
$name = "John Doe";
// i need some function ...
echo $text;
//Output --> Hello my name is John Doe

我想要的输出

Hello my name is John Doe

2 个答案:

答案 0 :(得分:0)

试试这个

<?php 
  // store your dynamic name into variable
  $name = "John Doe";
?>
// show like this 
<form><texteare>Hello my name is <?php echo $name; ?></texarea>

答案 1 :(得分:0)

试试这个:

<?php

  if(isset($_GET['hello'])){
    echo $_GET['textarevalue'];
  }

?>

  <form action="" method="get">
     <textarea name="textarevalue"></textarea>
     <input type="submit" name="hello"/>
  </form>