how to convert new line and html code in htmlspeci

2019-02-21 06:27发布

问题:

here is my string

hello


world



<textarea>hello world</textarea>

how can I convert this string

hello

&nbsp;

world

&nbsp;

&nbsp;

&lt;textarea&gt;hello world&lt;/textarea&gt;

in php. Any one help please... I am try htmlspecialchars(); function but that doesn't work perfect.

回答1:

please read more on php ..Maybe this can help you https://www.w3schools.com/pHp/default.asp

<?php

    echo "hello";
    echo "</br>";
    echo "world";
    echo "</br>";
    echo "</br>";
    echo "<input type = 'textare' value = 'hello world'>";
    ?>