Choose a language whilst browsing : PHP tutorial

Language selection preview

Ok! This tutorial is strictly targeted towards web developers, who are looking for ways to convey or show his/her web page(s) in more than one language. Here is one smart way of doing it.

I’ve made it very easy for you; I’ll give you the source-code and tell you what to do to get it working. Still have a problem? Leave a comment! I’ll help you get through.

Steps to follow
1) Create a .php file and name it “index”

then copy and paste this code inside index.php

2) Create a folder (in the same location where index.php is) and name it “choose”

then create an eng.php and a sin.php file inside “choose”

3) Paste this code inside eng.php :

$intro = “Hello!”;
$name = “My name is Ruzeen.”;

and paste this code inside sin.php :

$intro = “ආයුබෝවන!”;
$name = “මගේ නම රුසීන්.”;
(substitute the text according to your needs)

That’s it! You’re done.
You can easily change languages (by going through the code) to fulfill your needs.

– thanks for your comments

Share this post

Related Posts

6 thoughts on “Choose a language whilst browsing : PHP tutorial”

  1. Raques says:

    English only should be used… english is the main language of this world and deciding any other language just creates separatism and miscommunication between people.

    English is hands down the language of our lands… people need to use it more as its easily one of the better languages that have no problems really besides there being TOO MANY words!

    Anyone else who disagrees obviously does not speak much english and lives in a 3rd world country more than likely.

    1. Ruzeen says:

      First of all, this is just a tutorial!
      Different cultures have their own languages and customs, which we must respect. Only then will they have some respect for us and also English as a language. Hope you understand; what you’re trying to tell is just a misconception.

  2. This is great Ruzeen, I’m also going through some PHP tutorials these days and this helped a lot. Good work bro.

    1. Ruzeen says:

      You’re welcome 🙂 || will do more PHP and also JS tuts when I get some time…

  3. Andy says:

    You made some valid ideas there. I did a web search on the topic and found a good number people will have the same opinion with your site. Thanks once more for sharing this up. I certainly enjoyed every bit of it.

  4. Skip says:

    I like your tutorial quite easy to understand.

    Although I got one problem.
    When you switch to another page the settings of the language is gone.
    How can I keep the language the same at the whole website?

    Thanks in advance.

Comments are closed.