WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Submit Site
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Produces browser-safe strings while preserving HTML tags.
Categories : Strings, HTTP, PHP, HTML and PHP Update Picture
Jason Galvin
Date : Nov 06th 2000
Grade : 2 of 5 (graded 3 times)
Viewed : 3716
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Jason Galvin
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

<?
/* Produces browser-safe strings while preserving HTML tags.
* This function takes the string "ISTRING" as an argument and returns
* the string "OSTRING". All special characters from "ISTRING" are
* converted to browser-safe HTML codes using htmlentities(), and HTML
* tags are left intact and functional.
*/

// Contributed Nov 2000 by Jason Galvin: <www.jasongalvin.com>

function guardHTML($istring) {
$stringarr = preg_split('//', $istring);
$stringlen = count($stringarr);
for($i=0; $i<$stringlen; ++$i){
if($stringarr[$i] == "<"){
while($i<$stringlen){
$HTMLtag .= $stringarr[$i];
++$i;
if($stringarr[($i-1)] == ">") break;
}
--$i;
} else {
while($stringarr[$i] != "<" && $i<$stringlen){
$nonHTML .= $stringarr[$i];
++$i;
}
--$i;
}
$ostring .= $HTMLtag;
$HTMLtag = "";
$ostring .= htmlentities($nonHTML);
$nonHTML = "";
}
return $ostring;
}
?>



function textwrap will wrap text to any desired width using <BR>\n as the default line break. Default wrap width is 80 columns.
Categories : Strings, HTML and PHP, PHP
Customizable encoding and decoding strings with security.
Categories : PHP, Strings, HTML and PHP
PHP4 HTTP Compression Speeds up the Web
Categories : PHP, Zlib, HTML and PHP, HTTP, Network
Pull deliniated text strings into a "SELECT" statement in a form.
Categories : HTML and PHP, PHP, Strings
This script shows you the 7th latest php items from the mailing list archive on zend.com
Categories : HTML, HTML and PHP, HTTP, PHP
Pseudo Non Parsed Header. Output to the the browser as the script runs.
Categories : PHP, HTTP, HTML and PHP
How to let a user download a picture by clicking on it instead of needing to right click and Save-As.
Categories : HTTP, PHP, HTML and PHP, Filesystem
Browser Detection, Redirection Type, MSIE, MOZILLA, Netscape Navigator, NS, $HTTP_USER_AGENT, HTTP_USER_AGENT
Categories : PHP, HTTP, Browsers, HTML and PHP
Upload Script, Upload File Script, Input Type="File"
Categories : PHP, HTML and PHP, HTTP
Text Wrapping
Categories : PHP, HTML and PHP, Strings
string justification align center text
Categories : Strings, PHP, HTML and PHP
PHP3: Formmail. Just a cgi formmail, but than in PHP. It is easy to use!
Categories : HTML and PHP, Email, PHP, Perl, HTML and PHP
A simple class with some HTML output functions that would come in handy for consistent page layout etc.
Categories : PHP, PHP Classes, HTML and PHP, HTML, Navigation
a function that builds an HTML select list from any mysql table.
Categories : PHP, MySQL, HTML and PHP
Message of the Day - Random Message (Needs MySQL!)
Categories : Databases, HTML and PHP, PHP, MySQL