Jump to content

html entities does not work


dsaba

Recommended Posts

this is weird is there a setting in php.ini that turns off this?

i am using a freehost to upload .php files

(yes i know i can use my own pc)

 

anyways i copied the exact example from php.net

 

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

// Outputs: A 'quote' is <b>bold</b>
echo htmlentities($str);

// Outputs: A &#039;quote&#039; is <b>bold</b>
echo htmlentities($str, ENT_QUOTES);
?> 

 

and it did not work it gave me the string just like it is

 

why?

Link to comment
Share on other sites

hmmm it is like its supposed to be in the source

but the point of me using html entities is to make it look like that in the BROWSER

 

i'm trying to filter out any html tags for security purposes

 

is there a way i can do that?

Link to comment
Share on other sites

For the purposes of security, you might want to use strip_tags():

 

http://sg.php.net/manual/en/function.strip-tags.php

 

Regarding security, calling htmlentities() once should ensure that html is displayed, rather than interpreted by the browser.  You should see the bold tags instead of seeing bold text.

 

If you really want to see the htmlentities() output in the browser, call htmlentities() twice.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.