Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Displaying hebrew strings in php

Tags:

php

My code looks like this:

<?php
echo "בְּרֵאשִׁית, בָּרָא אֱלֹהִים, אֵת הַשָּׁמַיִם, וְאֵת הָאָרֶץ.";

The output in the webbrowser is:

בְּרֵ×ש×ִית, ×‘Ö¼Ö¸×¨Ö¸× ×ֱלֹהִי×, ×ֵת הַשּ×ָמַיִ×, וְ×ֵת ×”Ö¸×ָרֶץ.

Which steps should I take to make the browser to show:

בְּרֵאשִׁית, בָּרָא אֱלֹהִים, אֵת הַשָּׁמַיִם, וְאֵת הָאָרֶץ.
like image 221
Julian S Avatar asked Apr 14 '15 07:04

Julian S


1 Answers

You need to tell the browser that your page is utf8-encoded. This is done by setting the Content-type-header:

header('Content-type: text/plain; charset=utf-8');

Use text/html instead of text/plain if you want to print an html page.

like image 171
Al.G. Avatar answered Oct 02 '22 15:10

Al.G.