html tags inside php code

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
deathknight
Forum Newbie
Posts: 2
Joined: Fri Jun 09, 2006 8:52 pm

html tags inside php code

Post by deathknight »

I was lookin at a php script i downloaded from the internet and it had all the html tags inside php echo statements

I had a few questions about that if anyone knows the answers:
1. if you follow this method do you need all the tags such as <html> <head> <body>?
2. is there any great advantages/disadvantages to doing this?
3. any security issues with this approach?

thank you for any input
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: html tags inside php code

Post by Christopher »

1. if you follow this method do you need all the tags such as <html> <head> <body>?
Yes. Server side languages are meant to generate output, such as HTML or XML. That output needs to be correctly formatted per the specification for that language.

2. is there any great advantages/disadvantages to doing this?
Yes, you can enbed PHP variables in the output in a way that is often clearer than <?php ?> tags. Ultimately it is the way to separate the PHP language from the lanugage you are outputting.

3. any security issues with this approach?
Only if you are re-outputting data that you received from an untrusted source such as GET/POST/COOKIE.
(#10850)
deathknight
Forum Newbie
Posts: 2
Joined: Fri Jun 09, 2006 8:52 pm

Post by deathknight »

thx for the info

what kind of security issues? anything specific to avoid?
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Post by Roja »

deathknight wrote:what kind of security issues? anything specific to avoid?
arborint wrote:re-outputting data that you received from an untrusted source such as GET/POST/COOKIE.
Post Reply