Jump to content

[SOLVED] PHP Allow HTML Only?


Stalingrad

Recommended Posts

Hello! I'm working on the profile page for my website, and I

m having a little trouble. I want to be able to allow users to use HTML on their user lookups, and only HTML. (Well, and normal text, if they don't use HTML). How do I allow them to do so? Right now I'm using the strip_tags() function, but It strips the HTML tags too, which I don't want. Is there any wya to allow this? Any help is greatly appreciated. Thanks in advance. =]

Link to comment
Share on other sites

Thank you. But what do you mean the second arguement? May you please show me what the second arguement is and how to use it? Thanks. =]

 

From the very top of the page that you've been pointed to:

 

string strip_tags ( string $str [, string $allowable_tags ] )

 

$allowable_tags is the second argument... to find examples of its use, read that page

 

Link to comment
Share on other sites

Second argument for strip_tags is string not an array.

 

You have to put in it all tags, that you want NOT to strip.

 

$stripped = strip_tags($toBeStripped,"<a><p><b><i><img>");
// this will allow <a> <p> <b> <i> and <img> tags and strip all others

Link to comment
Share on other sites

$toBeStripped is the text from which you want to remove html tags (so in your case this is what user puts in their profile), and $stripped is same text after html tags are removed. These are just examples, and you should put your variable names instead.

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.