PHP

 Home  Computers & Internet  Web Programming PHP
What is PHP?
Echo
Comments
Variables
Constants
Data Types
number_format()
Character Strings
Mathematical Operators
Comparison Operators
Logical Operators
Joining Strings
explode()
implode()
strtolower()
strtoupper()
strlen()
ucfirst()
ucwords()
strrev()
str_replace()
str_repeat()
trim()
strip_tags()
addslashes()
stripslashes()
strpos()
strrpos()
nl2br()
isset()
unset()
empty()
POST
GET
If Statements
If Else Statements
Elseif Statements
Switch Statements
For Loops
While Loops
Do While Loops
Foreach Loops
File Create
File Open
File Read
File Write
File Delete
fgets()
file_get_contents()
Date & Time
$_SERVER
Sessions
Cookies
Arrays

HOW TO USE THE strip_tags() FUNCTION IN PHP

The strip_tags() function strips html tags from a string. It takes two parameters: the string to perform the action on and the specified html tags NOT to strip out. This is a useful function to prevent users from entering malicious scripts or unauthorized html onto your forms.

If the html tags to keep parameter is not specified, then strip_tags() strips all html tags by default.

Example:

$string="<b><i>John James was here</i></b>";
$newstring=strip_tags($string);

echo $newstring;

The above will output: John James was here

This output is neither bold nor in italics as all html tags were stripped out.

You can also specify what html tags to keep.

Example:

$string="<b><i>John James was here</i></b>";
$newstring=strip_tags($string, "<b>");

echo $newstring;

The above will output: John James was here

Note that the above is output in bold only as we told the function to keep the bold tags. The italic was stripped out.

Home | Privacy Policy | Terms Of Use | Contact Us