What is __( in php

I saw this on a php script, what does that mean (two underscores) ?

__('Read the rest of this page')

Who is Participating?
jchookConnect With a Mentor Commented:
__('This is used for internationalization in WordPress');

Internationalization (abbreviated i18n (see http://en.wikipedia.org/wiki/Internationalization_and_localization)) is a way of providing translations for the text on a website or other software.

Developers wrap all of the various chunks of text for a website or application in the simple function __. Then, translators can create language files that literally map specific phrases from one human language to another.

So, for example, if your website code has __('The Example'); written somewhere, and the language flag is set to French, the page will display 'L'exemple' instead of 'The Example', so long as there is a French language file that correctly connects the two.

However, this may not always be the case.

In PHP, you can define the function __ to do anything you want. For example:

function __($a) {
  return strrev($a);

The function above will reverse any string.

print __('hello'); // outputs olleh
print __('racecar'); // outputs racecar

The short answer is: It is entirely based on context.
Greetings sahanz,

__ its magic methods..

Refer the below url...its main future of PHP5


more methods availbale..like __call, __get...
Dushyant SharmaCommented:
PHP automatically creates variable and assigns values to it even is the variables are not defined. But in Object Oriented Programming all the data members/methods needs to be defined.

Magic methods are used to solve this problem. PHP reserves all function names starting with __ as magical.

These methods for overloading purpose. Please refer http://php.net/manual/en/language.oop5.overloading.php
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Lukasz ChmielewskiCommented:
Ray PaseurConnect With a Mentor Commented:
Double underscores are reserved by PHP, and apparently used in a quirky (possibly conflicting and dangerous) way in WordPress.

Single underscores get used in Drupal.

So the executive summary is, if you have PHP don't name anything starting with a double underscore.  And if you have a CMS don't name anything starting with an underscore.
sahanzAuthor Commented:
Btw this is not a magic method right?
Ray PaseurCommented:
Please see this page:

HTH, ~Ray
sahanzAuthor Commented:
Thank You
All Courses

From novice to tech pro — start learning today.