Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
"echo htmlentities" -v- "echo" : Whats the difference.
Old 09-11-2008, 11:17 PM "echo htmlentities" -v- "echo" : Whats the difference.
TWD
TWD's Avatar
King Spam Talker

Posts: 1,190
Trades: 0
I`ve never been clear on when, where or why to use echo html entities versus just a simple echo statement.

Could someone advise?

Does it mean for example that if I am echoing a block of text which contains quotation marks (ex. Elvis "The King" Presley) html entities will render the quotations in HTML friendly format? (ex. Elvis "The King" Presley)

??

I currently have a problem where I`m trying to do something like that.
I want to echo a text block into the title tag but HTML interprest the first quotation marks it encounters as the end of the title attribute.
Should I be using html entities for this?

thnks
TWD is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-12-2008, 02:07 AM Re: "echo htmlentities" -v- "echo" : Whats the difference.
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
I use htmlentites() to output text with double quotes into tag attributes, e.g. <a title=""> or <input value=""> because double quotes may break the page rendering. Echoing text with double quotes into tags theirselves, like <title> or <p> or <textarea> cannot do any harm, so htmlentities() is not neccessary in this case. Also you need to use htmlentities() if you output text that can possibly contain html and you want this html to be shown as text and not rendered by the browser, e.g. when you want to place an example of code on your page.

Use all functions wisely. None of them will do what you want if you simply pass EVERYTHING through it.
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 09-12-2008, 03:14 AM Re: "echo htmlentities" -v- "echo" : Whats the difference.
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
Should I be using html entities for this?
Yes

or htmlspecialchars()

htmlentities will convert ALL ASCII characters that have an "entity" equivalent specialchars will only convert the ", ', &, <, > characters.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to "echo htmlentities" -v- "echo" : Whats the difference.
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.19141 seconds with 12 queries