开发者

What does the function _($string) do in PHP?

I noticed this piece of code in Wordpress 2.9.1 (/wp-includes/compat.php), I don't understand it:

if ( !function_exists('_') ) {
  function _($string) {
    return $string;
  }
}

It seems that PHP i开发者_如何学运维ndeed has a function _($string) but I can't find the documentation for it.


It is an alias for gettext()


_ is an alias for the gettext function for translating.

gettext takes the original string as input, and finds the translation for it. This approach has the advantage that if a translation does not exist, you'll get a sensible default string out of it.

To mirror this property, the code you found essentially creates an "always failing" version of this function in case gettext isn't available.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜