Home » , , , » Concatenate html tags to string in php

Concatenate html tags to string in php

Written By Unknown on Selasa, 29 Oktober 2013 | 23.07

To add html tags to string in php ... You have to concatenate html tags with string using htmlentities()
as shown below
$newstring="<u>".htmlentities("test")."</u>";
Here i have added <u> tag to my string test which is passed to htmlentities() function for concatenation.

For more details see the example
Example:

<?php
$mystring="Hello ... This is my test string . I am testing it for htmlentities()";
echo "This is string before adding html tags"."</br>";
echo "</br>";
echo $mystring;
echo "</br>";
echo "</br>";
$newstring="<u>".htmlentities("test")."</u>";
$finalstring=str_replace("test",$newstring,$mystring);
echo "This is string after add html tags"."</br>";
echo "</br>";
echo $finalstring;
?>


htmlentities
Share this article :

Posting Komentar

 
Support : Creating Website | Johny Template | Mas Template
Copyright © 2011. Kumpulan Kata Broadcast Blackberry - All Rights Reserved
Template Created by Creating Website Published by Mas Template
Proudly powered by Blogger