How To Convert Characters To HTML Entities With PHP Function Script Code

Mobile
feeds
Welcome Login | Register

How To Convert Characters To HTML Entities With PHP Function Script Code
  Forums Index
      » PHP Forums
        » » how to convert characters to HTML entities with PHP Function Script Code



How To Convert Characters To HTML Entities With PHP Function Script Code
Post Description:
Post Tags: how, to, convert, characters, to, html, entities, with, php, function, script, code, free php support, php scripts, php questions, php answers, programming, codes, scripts
This Post Has Been Viewed 419 Times Since Mon May 28, 2007 4:01 pm Posted By webune with 2 replies
How To Convert Characters To HTML Entities With PHP Function Script Code
ok, so today i wanted to change a character into special html characters. some examples are when users enter their name is a foreign language other than english. some characters have accents and some search engines don't like that and some validation tools show as error:

so lets say for example i have this name:
ToledÃÆ’£o

what you see is looks like toledafaeo right, well, that's how the browser shows it to you, but if you look at this page HTML code, you will see that it looks something like this:

Toledão


well, how do you do it. PHP is great for this.

if you dont have PHP yet on your website, i recommend you use our friends at www.webune.com, they have great service in hosting packages.

so if you have PHP, lets continue.. lets follow the example with this name so to display it properly i would use the htmlentities() function and this how my script would look like:

CODE:
<?
echo htmlentities("ToledÃÆ’£o");
?>


OUTPUT:
ToledÃÆ’£o


hope this helps..
Description
string htmlentities ( string $string [, int $quote_style [, string $charset]] )
This function is identical to htmlspecialchars() in all ways, except with htmlentities(), all characters which have HTML character entity equivalents are translated into these entities.
Like htmlspecialchars(), the optional second quote_style parameter lets you define what will be done with 'single' and "double" quotes. It takes on one of three constants with the default being ENT_COMPAT:

if you want more information visit php.net at:
http://us.php.net/htmlentities


Leave Your Comments






Share
URL:
You can use this HTML code to put it on your website to show your friends this wallpaper. Use this code on your profile like myspace, friendster, Facebook or others. Just Copy and Paste it in your HTML on your websites



Fourms BBCODE:
BBCODE is use on forums. You can put this code on all your BBCODE enabled forums like PhpBB, vBulletin® and others. Just Copy and Paste this code on your Posts and Replies on your forums





Comments and replies About How To Convert Characters To HTML Entities With PHP Function Script Code




:: 1 :: Reply #4535 Reply By Toledão On Mon May 28, 2007 4:11 pm
nice, so how are you goin to display it if i enter: toledão on my comments?
:: 2 :: Reply #75793 Reply By steve On Thu Oct 16, 2008 12:17 pm
thank you it is very helpmfl when wring new sites

im a websmaster and i will save this infor

this is a keepr