0
<div id="userpost">
<?php echo $txt; ?>
</div>

<?php $txt="yeah yeah"; ?>

I want the echo on the div to be the normal text but if you look at the source it would be something like this

&#89;&#101;&#97;
4
  • 1
    Not sure about your server setup, but mine wouldn't response to <php>...perhaps you meant <?php ?? Commented Feb 28, 2011 at 5:38
  • is that source code or source in the browser? Check the encoding of the file Commented Feb 28, 2011 at 5:39
  • htmlentities($txt); maybe ? Commented Feb 28, 2011 at 5:41
  • As long as it's being displayed correctly as html, don't worry about the source. Can you provide us link to the live site for testing? Commented Feb 28, 2011 at 6:21

1 Answer 1

5

Hope this would help you

<?php
$new = htmlspecialchars("<a href='test'>Test</a>", ENT_QUOTES);
echo $new; 
?>

for detail

http://php.net/manual/en/function.htmlspecialchars.php

Sign up to request clarification or add additional context in comments.

1 Comment

yes something like that but i don't want the html tags to be encoded only the text inside it "test" i had more description on my question but don't know what happened sorry for the confusion. here is an example labs.net63.net

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.