View Single Post
Old 01-21-2008, 11:58 AM   #3 (permalink)
Salathe
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

The simple answer to your question is, no. Trying to use a constant of any kind (class or global) will result in a parse error, "syntax error, unexpected T_CONST, expecting T_VARIABLE". The error is pretty self-explanatory, the PHP engine expects a standard, normal, garden-variety variable (a reference or otherwise) as an argument.

If you were to try this with a static variable (public static $test = ... and self::$test as the function argument) then you would also get a parse error, this time saying: "syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM, expecting '&' or T_VARIABLE". Again it's clear that PHP really, really only wants a regular variable in there (the T_PAAMAYIM_NEKUDOTAYIM is just a constant for the '::' or T_DOUBLE_COLON operator).

If you tried to use an object property as the argument ($this->test) then I think you can guess the likely outcome from the examples given so far.

In short, you can only use a normal variable ($test) or reference (&$test) as arguments.
Salathe is offline  
Reply With Quote
The Following User Says Thank You to Salathe For This Useful Post:
Orc (01-21-2008)