1

I have a PHP function from the Internet like this:

function Del_Inflection_Suffixes($kata) {
    $kataAsal = $kata;
    if(preg_match('/([km]u|nya|[kl]ah|pun)$/', $kata)) { // Cek Inflection Suffixes
        $__kata = preg_match_replace('/([km]u|nya|[kl]ah|pun)$/', '', $kata);
        if(preg_match('([klt]ah|pun)$', $kata)) { // Jika berupa particles (“-lah”,     “-kah”, “-tah” atau “-pun”)
            if(preg_match('/([km]u|nya)$/', $__kata)) { // Hapus Possesive Pronouns (“-ku”, “-mu”, atau “-nya”)
                $__kata__ = preg_match_replace('/([km]u|nya)$/', '', $__kata);
                return $__kata__;
            }
        }
        return $__kata;
    }
    return $kataAsal;
}

What is the meaning of $___kata and $_kata?

Is that the same as $kata on the top of function?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Sandhi
  • 89
  • 2
  • 11
  • there is no special meaning of it just user defined variables. – Abhik Chakraborty Mar 22 '14 at 10:28
  • 1
    I'm almost sure that it is just a variable and it doesn't have any special meaning. – MrByte Mar 22 '14 at 10:28
  • *NOTE* Yes They don't have any special meaning but It mostly using in the PHP Magic functions – underscore Mar 22 '14 at 10:30
  • Like the others have said, there is no special meaning. But in PHP there are functions and a few variables that start with underscores, such as __construct. Personally I use underscores at the start when I want to make sure I don't touch that variable by mistake since it's needed by another function. – David Mar 22 '14 at 10:30
  • 2
    looks like it's just a recommendation to differentiate between types of functions / variables, have a look at [this answer](http://stackoverflow.com/questions/19554835/functions-and-variables-beginning-with-a-single-or-double-underscore) – benomatis Mar 22 '14 at 10:30
  • woww very fast answer :D thanks all for the fast response and the answers..very helpful for me..now i can understand what the meaning of.. – Sandhi Mar 22 '14 at 10:46
  • Related (not a duplicate, despite the title): *[Double underscore in PHP](https://stackoverflow.com/questions/1777131/double-underscore-in-php/1777147#1777147)* – Peter Mortensen Feb 23 '22 at 14:01

2 Answers2

4

Some coders use underscore to identify some types of variables: $__constant, $simplevariable.

Other than that, it means nothing in PHP as it is not a pre-defined function. However, in many frameworks, like CakePHP, and other libraries, the double underscore is a function used for translating strings based on the user's language/locale preference.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
sunny
  • 1,156
  • 8
  • 15
  • The last part is also covered in *[Double underscore in PHP](https://stackoverflow.com/questions/1777131/double-underscore-in-php/1777147#1777147)*. – Peter Mortensen Feb 23 '22 at 14:10
2

They are different variables. They aren't related in any special way. $foo, $__foo__ and $__foo are all simply different variables like $a, $b, $c.

Madara's Ghost
  • 172,118
  • 50
  • 264
  • 308