0

Suppose when I am passing the variable $company to another static function, what is the meaning of passing the like this? Is there any unique importance?

CompanyMaster::getRowfromCompany($company_);

Instead of $company, why it is given as $company_ ?

nickb
  • 59,313
  • 13
  • 108
  • 143
Naren Karthik
  • 349
  • 2
  • 9
  • 1
    Where do you have this example from? – Pekka Jul 06 '12 at 12:41
  • It's a common (if aged) naming convention, the further you go back to ADA-times the more often you will find programmers using it ;-) see http://stackoverflow.com/questions/3650623/trailing-underscores-for-member-variables-in-c – VolkerK Jul 06 '12 at 13:39

2 Answers2

0

Suppose when I am passing the variable $company to another static function, what is the meaning of passing the like this(as below)? Is there any unique importance??

No, there's no special meaning to the added underscore. If you don't like it, remove it :)

Berry Langerak
  • 18,561
  • 4
  • 45
  • 58
  • do you mean $company and $company_ are both same?? – Naren Karthik Jul 06 '12 at 12:43
  • 1
    No, it's just the variable naming convention used in your application. Variables appended with underscores have no special meaning in PHP. – Mike B Jul 06 '12 at 12:43
  • Whoever named the variable added an underscore at the end. Probably to indicate either that it's an argument to the function it's in, or it's a private field. Conventions vary a bit. But PHP doesn't care what the name is, as long as you use the same name in both places. – cHao Jul 06 '12 at 12:44
0

There is no special meaning to the underscore in your script.

$company and $company_ are not the same variable, but they have the same meaning, I mean - the underscore doesn't do anything special.

But don't be confused - there are also magic constants - which are not variables, but they do contain double underscores, and provide special information.

Nadav S.
  • 2,429
  • 2
  • 24
  • 38