Forum Moderators: coopster

Message Too Old, No Replies

PHP OOP Function Syntax

         

OhNoMrBill

6:53 pm on Dec 5, 2007 (gmt 0)

10+ Year Member



What does the _ and & prefix mean when applied to php functions/variables?

ex:
public function &myVariable() {
$myVariable = &someFunction($someParam);
return $myVariable;
}

Thanks!

eelixduppy

7:38 pm on Dec 5, 2007 (gmt 0)



Welcome to WebmasterWorld!

The ampersand (&) before a variable makes it a reference. More here: references explained [us2.php.net].

The double underscore (__) before the function identifier can have a couple different meanings. I suggest that you read some of the documentation on classes: Classes and Objects (PHP5) [us2.php.net].

OhNoMrBill

8:36 pm on Dec 5, 2007 (gmt 0)

10+ Year Member



Thanks. The variable aspect makes perfect sense. Having a little trouble getting my head around function names declared as references. What is that intended to do?

Thanks again!

coopster

3:50 pm on Dec 7, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



It allows you to pass a function argument by reference [php.net]