SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Guru
    Join Date
    Nov 2008
    Posts
    848
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Purpose of 2 underscores

    Hi why are the double underscores used in PHP, such as the following line?

    "std" => __(""),

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2005
    Posts
    1,191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In that code it is just a function name __ ie no different from aa();

    In general the double underscore is used for "magic" methods and variables, eg __get(), but as far as I am aware the significance of underscores is nothing more than a naming convention.

  3. #3
    @php.net Salathe's Avatar
    Join Date
    Dec 2004
    Location
    Edinburgh
    Posts
    1,397
    Mentioned
    65 Post(s)
    Tagged
    0 Thread(s)
    In PHP, _() is an alias to the gettext() function. Other systems (e.g. Wordpress) extend this idea and use double-underscore (__("blah")) for translations.
    Salathe
    Software Developer and PHP Manual Author.

  4. #4
    SitePoint Guru
    Join Date
    Nov 2008
    Posts
    848
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok, ive seen it in my wordpress code so its something to do with translations, thanks


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •