What does the double underscores in these lines of PHP code mean?
$WPLD_Trans['Yes'] = __('Yes', $WPLD_Domain); $WPLD_Trans['No'] = __('No', $WPLD_Domain);
__ in PHP is for magic methods like __get , __set , __clone. Historically _ before variable or function means it's private since there was no private, public or protected methods in PHP 4 . It is applied not only to PHP . In Python for example, _ prefix for functions and variables is used for the same purpose.
PHP functions that start with a double underscore – a “__” – are called magic functions in PHP. They are functions that are always defined inside classes, and are not stand-alone functions.
In PHP, the underscore is generally reserved as an alias of gettext() (for translating strings), so instead it uses a double-underscore. All the functions that make up the library are available as static methods of a class called __ – i.e., a double-underscore.
@froedrick double underscore is translation of the text. So, if you want to use multiple languages - you'll be able to easily define translations for this text. By default (if no translation defined for the current language) it will displays text as it is. 2. Level 50.
It looks like you're using WordPress - wp-includes/l10n.php
defines __ as a function that translates a string (similar to gettext
and its alias, _
, but with an optional parameter for explicitly specifying a domain).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With