Moodle PHP Documentation 5.1
Moodle 5.1dev (Build: 20250620) (7d9030acd6e)
core\lang_string Class Reference

Public Member Functions

 __construct (protected string readonly string $identifier, ?string $component='', mixed $a=null, protected string readonly ?string $lang=null,)
 Constructs a lang_string object.
 
 __sleep ()
 Prepares the lang_string for sleep and stores only the forcedstring and string properties... the string cannot be regenerated so we need to ensure it is generated for this.
 
 __toString ()
 Magic __toString method for printing a string.
 
 get_component ()
 Returns the component.
 
 get_identifier ()
 Returns the identifier.
 
 out ($lang=null)
 Returns the string.
 

Static Public Member Functions

static __set_state (array $array)
 Magic __set_state method used for var_export.
 

Protected Member Functions

 get_string ()
 Processes the string.
 

Protected Attributes

array stdClass mixed $a = null
 Any arguments required for the string.
 
string string $component = ''
 The strings component.
 
bool bool $forcedstring = false
 A special boolean.
 
string string $string = null
 The processed string (once processed)
 

Constructor & Destructor Documentation

◆ __construct()

core\lang_string::__construct ( protected string readonly string $identifier,
?string $component = '',
mixed $a = null,
protected string readonly ?string $lang = null )

Constructs a lang_string object.

This function should do as little processing as possible to ensure the best performance for strings that won't be used.

Parameters
string$identifierThe strings identifier
string | null$componentThe strings component
mixed$aAny arguments the string requires
string | null$langThe language to use when processing the string.
Exceptions
coding_exception
Parameters
$identifierThe strings identifier
$langThe language to use when processing the string

Member Function Documentation

◆ __set_state()

static core\lang_string::__set_state ( array $array)
static

Magic __set_state method used for var_export.

Parameters
array$array
Return values
self

◆ __sleep()

core\lang_string::__sleep ( )

Prepares the lang_string for sleep and stores only the forcedstring and string properties... the string cannot be regenerated so we need to ensure it is generated for this.

Return values
array

◆ __toString()

core\lang_string::__toString ( )

Magic __toString method for printing a string.

Return values
string

◆ get_component()

core\lang_string::get_component ( )

Returns the component.

Return values
string

◆ get_identifier()

core\lang_string::get_identifier ( )

Returns the identifier.

Return values
string

◆ get_string()

core\lang_string::get_string ( )
protected

Processes the string.

This function actually processes the string, stores it in the string property and then returns it. You will notice that this function is VERY similar to the get_string method. That is because it is pretty much doing the same thing. However as this function is an upgrade it isn't as tolerant to backwards compatibility.

Return values
string
Exceptions
coding_exception

◆ out()

core\lang_string::out ( $lang = null)

Returns the string.

Parameters
string$langThe langauge to use when processing the string
Return values
string

Member Data Documentation

◆ $a

array stdClass mixed core\lang_string::$a = null
protected

Any arguments required for the string.

Default null

◆ $component

string string core\lang_string::$component = ''
protected

The strings component.

Default ''

◆ $forcedstring

bool bool core\lang_string::$forcedstring = false
protected

A special boolean.

If set to true then the object has been woken up and cannot be regenerated. If this is set then $this->string MUST be used.


The documentation for this class was generated from the following file: