dshakcsq64956 2016-05-24 02:35
浏览 108
已采纳

使用PHP向TextArea添加换行符

I want to add Line break in a textarea placeholder using php.

Code:

<!DOCTYPE html>
<html style="height: 100%;">

<head>
  //stuff
</head>

<body>
  //stuff
  <div id="editContainer">
      <textarea id="note" name="note" placeholder="Placeholder Text"></textarea>
  </div>
  //stuff
</body>
</html>
  • 写回答

1条回答 默认 最新

  • douao1579 2016-05-24 02:39
    关注

    This Should Work:

    <textarea placeholder="<?php
    $data = 'Line Number One,-,Line Number Two';
    $ndata = str_replace(',-,',"
    ",$data);
    print "$ndata"; ?>"></textarea>
    

    You can change the ,-, in the third line to anything that suits you.

    Here's some pointers:

    • Make sure you rename your file to .php
    • Make sure you use a local server or online server to parse the code.
    • HTML Comments are Written as <!--Comment--> not as //comment(that's JavaScript)
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?