simonwjackson
simonwjackson

Reputation: 1878

PHP: Does $_this have a special meaning?

I cant seem to find any documentation on what $_this means in PHP. It seems to be used quite a bit in the CakePHP framework.

Any ideas?

Upvotes: 1

Views: 2479

Answers (4)

spoulson
spoulson

Reputation: 21591

CakePHP follows a general nomenclature where variables starting with $_ are considered private to the class. They are not important for using the framework, however.

Upvotes: 8

Brad
Brad

Reputation: 5488

An underscore typically denotes the scope of the variable. A variable with a leading underscore often means that it is protected or private. This is just a convention and is not enforced by the language. It helps make the code easier to read.

Upvotes: 4

Corey Ballou
Corey Ballou

Reputation: 43457

Many individuals like to use some form of variable naming convention. In the case of private variables, people like to use $_ as a convention. I don't particularly know if this is the case in CakePHP, but elsewhere it's frequently seen.

Upvotes: 3

Deniss Kozlovs
Deniss Kozlovs

Reputation: 4841

$_this is not of any PHP reserved keywords ($this however, is). Perhaps some kind of special variable in CakePHP.

Upvotes: 2

Related Questions