Short Tag – Web Development Blog

Entries for April 16th, 2010

Change the character set of your page with PHP and HTML

When using special characters you need to set the character set of your page, otherwise each browser uses the character set it pleases.
Let’s say my backend uses UTF-8 character set, then my frontend should use UTF-8 as well.
HTML code:
<meta http-equiv=”content-type” content=”text/html; charset=utf-8″ />
PHP code:
header(‘Content-type: text/html; charset=”utf-8″‘);
I use the both , but one should be [...]

Get the domain of an e-mail address with PHP

function getEmailDomain($email)
$email = trim($email);
$emails = explode(@, $email);
return trim($emails[1]);