'What are these underscores in PHP? [duplicate]
Possible Duplicate:
Double underscore in PHP
In a PHP application that I am inheriting, there exist these code snippets which I have trouble comprehending:
$foo = bar(array(
'format' => '',
'prev_text' => __('«'),
'next_text' => __('»'),
));
And another example:
$some_text = sprintf( '<span>' . __( 'Displaying %s–%s of %s' ) . '</span>%s',
number_format_i18n( ( $current_page - 1 ) * $per_page + 1 ),
number_format_i18n( min( $current_page * $per_page, $total ) ),
number_format_i18n( $total ),
$page_links
);
What are those double underscores? I tried looking for a method whose name is just a double underscore but found none. What might that be, then?
Solution 1:[1]
A single underscore is an alias to gettext(). I would assume a double underscore would be a function used for a similar purpose.
Solution 2:[2]
It looks like WordPress's localization mechanism: Translator’s Handbook – Translate WordPress
(A decent IDE, such as PhpStorm or NetBeans, can lead you straight to a function declaration.)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Jani Hartikainen |
| Solution 2 | Peter Mortensen |
