Note: You are currently viewing documentation for Moodle 1.9. Up-to-date documentation for the latest stable version is available here: Using variables in localization strings.

Using variables in localization strings

From MoodleDocs

Language strings are defined as follows:

$string['stringname'] = 'This is a string';

and are called via:

get_string("stringname","wherefrom")

If you wish to use a variable from the calling page in the string then you will need to use the following variation to call it:

get_string("stringname","wherefrom","passedvariable")

The variable can then be used in your string as follows:

$string['stringname'] = 'This is a string with a variable called $a';