Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

Christhoper Key
PLUS
Christhoper Key
Courses Plus Student 2,061 Points

Browser URL with lang path

Hello! I have a question about URL.

So I would like to add language path into the browser URL bar. For example: https://mysite.com/EN/index.php https://mysite.com/RUS/index.php


I have no idea how to even search for such a information into the net. Can anyone help me out with some keywords for getting on the right path for this system?

3 Answers

search for URL QUERY STRINGS.

Christhoper Key
PLUS
Christhoper Key
Courses Plus Student 2,061 Points

I'm not sure if I get it at all. Could you explain in details?

You can use Query parameters to pass additional information from client to server. Each will be composed by a question mark, a key, an equal sign and a value. In your case, you would use something like https://mysite.com?lang=en or https://mysite.com?lang=rus. You would then GET the lang parameter value from the url ($_GET["lang"], don't forget to filter and validate).

I would suggest taking the "Build a Basic PHP Website" course. This lesson from it talks about that:

https://teamtreehouse.com/library/working-with-get-variables

I would like to add that this is just a suggestion, for a quick, easy and beginner friendly solution. You'll see it on several websites.

If you start using a router, for example, you could then, of course, do it in a different way. In Laravel, you'll have the Localization features to help you with that, etc...