Working with Persian/Farsi on a Website HTML / PHP / MYSQL

By

It took me a few hours to figure this out. Though it turned out to be quite simple. Everything needs to be in UTF-8.

HTML

Use the charset meta tag below:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>

MYSQL

The field needs to be collated “utf_8_persian_ci”.

PHP

Set the charset

At the top of the document specify:
header(“Content-type: text/html; charset=utf-8”);

Set the database

Just after opening the database connection specify utf-8 with the following command:
mysql_set_charset(‘utf8’);

FARSI FONTS

Optionally, these open-source fonts can be uploaded and used with @fontface in the stylesheet.

http://www.farsiweb.ir/wiki/Persian_fonts