|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 18:00:02 2025 UTC |
Simply adding another comment for testing purposes. Sorry. <?php /* How does it do on code? */ ?> <?php # I can't type a TAB, but what if I paste it? $date = date('M d Y'); $query = "select album_title, inventory.quantity, band_name, email_address, fname, lname "; ?>Does it support <b>some</b> <i>HTML</i> ? Or even (<script language="JavaScript"><!-- // alert('JavaScript !'); //--></script>JavaScript) ? what about the <pre> <pre> tag ? </pre> ?May I suggest to use the two following functions. The first one is to get rid of JavaScript and unwanted stuff before storing to the database ; the second one for automagic formatting while displaying the stored message. It's useful to have two functions for cases when one can edit the message. function msgClean($txt) { /* SCRIPT PATTERN MATCHING */ $txt = preg_replace("/<script([\n\r]*.*)>([\n\r]*|[^>]*.*)<\/script>/i",'',$txt); /* STRIP UNWANTED HTML TAGS */ $txt = strip_tags($txt,"<b></b><i></i><u></u>"); return $txt; } function msgFormat($txt) { /* PLEASE KEEP THAT IN ORDER -- how */ /* LINK MATCHING PATTERN */ $txt = preg_replace("/([[:alpha:]]+):\/\/([\w\d-#\?=\/&]+[^\s_]+)(?<![,.:;])/i",'<a href="\1://\2">\1://\2</a>',$txt) /* EMAIL MATCHING PATTERN */ $txt = preg_replace("/(?!mailto:)([[:alnum:]-.]+)@([[:alnum:]-.]+\.[[:alnum:]]{1,3})(?<![,.:;])/i",'<a href="mailto:\ /* PARAGRAPH MATCHING PATTERN */ $txt = preg_replace("/(\r\n\r\n|\n\n)/i",'<p>',$txt); /* SINGLE LINE MATCHING PATTERN */ $txt = preg_replace("/(\r\n|\n)/i",'<br />',$txt); return $txt; }