zero-perfoliate
zero-perfoliate

Author Topic: Outputting text with appended contant?  (Read 318 times)

Offline tankjer

  • New PHP Members
  • Posts: 1
  • Karma: +0/-0
Outputting text with appended contant?
« on: May 28, 2010, 03:15:33 PM »
Hello, it's my first post on these forums. :)
I have a problem with this code:
Code: [Select]
<?PHP
    $lang = $_GET['lang'];
    define('text_en', 'WORKS');
    define('text_pl', 'DZIALA');
    echo ("text_$lang");
?>
I want that php file will recognize the language provided in the url (ex. index.php?lang=en) and then echo the text corresponding to that language (ex. text_en). The problem is, that the php outputs "text_en" or "text_pl", when it should output constant corresponding to it (ex. WORKS). I'm fairly new in PHP, and I'm learning only by googling, but I couldn't find solution to this so I write there.
Cheers for any help,
Tankjer.

Offline Andrei

  • Administrator
  • PHP Workers
  • *****
  • Posts: 11
  • Karma: +0/-0
Re: Outputting text with appended contant?
« Reply #1 on: May 29, 2010, 08:35:57 AM »
Hello,

 use echo constant("text_$lang");

 Cheers,
  Andrei

 

zero-perfoliate