Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6597075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:09:43+00:00 2026-05-25T18:09:43+00:00

I have a function for language (like the system that WordPress and other CMSes

  • 0

I have a function for language (like the system that WordPress and other CMSes have) to retun a term in defined language as

function lang($term) {
include "language/cn.php"; 
if(!empty($tans[$term])) {$translatedterm=$tans[$term];} 
else { $translated = $term;}
return $translated;
}

The problem is that I want to offer the option of choosing language on menu, as people can change the language. To this aim, I need to update the value of “include ‘language/cn.php'” for every language. It should be include "language/$language.php"; but $language is a string coming from menu selection and is outside the function. Do you have any idea how to change the language file inside the function depending on the language selected?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T18:09:44+00:00Added an answer on May 25, 2026 at 6:09 pm

    According to the hint given by Alex Howansky, the ultimate solution is to use a php variable like $_SEESION, $_GET, $_POST, etc. These variable can be used within a function. However, as a function has its own scope, a static string from outside a function cannot be read inside the function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say we have a simple function defined in a pseudo language. List<Numbers> SortNumbers(List<Numbers>
I have this simple code that speaks for itself. <script language='javascript"> function check() {}
In my interpreter I have built-in functions available in the language like print exit
In most other Object Oriented languages. it would be sacrilege to have each function
i have function public Menu Details(int? id) { return _dataContext.Menu.Include(ChildMenu).FirstOrDefault(m => m.MenuId == id);
I have function getCartItems in cart.js and I want to call that function in
let say i have function like below function doSomethingNow(){ callSomethingInFutureNotExistNow(); } at the moment
Sadly, I have a legacy PHP4 system that I continuously need to add features
So let us say that I have a menu system with all the navigation
I have a UserControl that has some javascript I'd like to inject into a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.