SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Oct 2000
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi

    I want to filter a form input for html/php tags.

    So far I've got this.

    <?
    $text = "<test> after a couple of spaces";
    echo nl2br(ereg_replace(" ", "&nbsp;", strip_tags($text)));
    ?>

    If the $text contains a " (double quot charachter) the script will produce a parse error. Does someone know a solution for this?

    Thanx in advance

  2. #2
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Simply escape the double quotes with backslashes:

    $text = "This is what we call a <I>\"TEST\"</I>!";

    [Edited by kyank on 10-21-2000 at 10:19 PM]
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •