I can't figure out how to post this without the characters being translated so I just used (html) in place of the characters. Here's the post:

I can't get htmlentities to work. This is my code right from the php manual:

<?php
$str = "A 'quote' is <b>bold</b>";

echo htmlentities($str);

echo htmlentities($str, ENT_QUOTES);
?>

It says it should output this:

A 'quote' is &lt;b&gt;bold&lt;/b&gt;
A (html)quote(html) is &lt;b&gt;bold&lt;/b&gt;

But it outputs this:

A 'quote' is <b>bold</b>
A 'quote' is <b>bold</b>

I'm trying to translate textfield entries into html. So "I'm" becomes "I(html)m"

    I got the code from the manual:
    http://php.net/manual/en/function.htmlentities.php

    <?php
    $str = "A 'quote' is <b>bold</b>";
    
    // Outputs: A 'quote' is &lt;b&gt;bold&lt;/b&gt;
    echo htmlentities($str);
    
    // Outputs: A 'quote' is &lt;b&gt;bold&lt;/b&gt;
    echo htmlentities($str, ENT_QUOTES);
    ?> 

      Yes but did you check the HTML output, not the page in the browser but the source?

        Write a Reply...