Convert HTML code in PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
janakghij
Forum Newbie
Posts: 1
Joined: Mon Apr 09, 2012 11:31 pm

Convert HTML code in PHP

Post by janakghij »

Hi all,
How we can convert the HTML code in the PHP code what special code is used for converting the HTML code in PHP?
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: Convert HTML code in PHP

Post by social_experiment »

Could you clarify what is meant by "convert"? To make html characters like < and > (among others) 'safe' for display purposes, you can use htmlentities() or htmlspecialchars(). If you are refering to simply displaying html via php, there is no special code; you just echo it

Code: Select all

<?php echo '<h1>A header</h1>'; ?>
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Post Reply